File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -561,10 +561,16 @@ def create_backup(
561561 # Delete older backups if exceeding max_backups
562562 try :
563563 result = c .run (f"ls -1t { backup_path } /{ site_name } _*.tar.gz" ,
564- hide = True , warn = True )
564+ hide = True , warn = True )
565+
566+ # Initialize files as an empty list by default
567+ files = []
568+
569+ # Only assign to files if there are results
565570 if result and result .stdout :
566571 files = result .stdout .strip ().splitlines ()
567572
573+ # Now we can safely verify len(files)
568574 if len (files ) > max_backups :
569575 old_files = files [max_backups :]
570576 for file in old_files :
@@ -821,7 +827,7 @@ def acquire_lock(
821827 c .sudo (f"chmod 664 { lock_file } " )
822828
823829 # Write lock file to remote system
824- c .run (f"printf '{ content } ' | sudo tee { lock_file } > /dev/null " )
830+ c .run (f"sudo bash -c \" echo '{ content } ' > { lock_file } \" " )
825831 logger .info ("Deployment lock acquired." )
826832
827833 return lock_id
You can’t perform that action at this time.
0 commit comments