Skip to content

Commit 20e5d4b

Browse files
committed
Correción al escribir en el archivo de bloqueo de deploy
1 parent b245cc6 commit 20e5d4b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fabricator/recipes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)