From 798d4e089022464defcb5e7436a35277f6afc7c7 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 13 Nov 2026 11:12:22 +0100 Subject: [PATCH] Fixed leftover upload dirs in sftp cache cache-sftp putdir left tmp/cache-sftp.putdir.* behind on the server when the rename failed (package already uploaded by another build) or when the upload aborted. These piled up until the cache disk was full. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Lars Erik Wik --- deps-packaging/cache-sftp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/deps-packaging/cache-sftp b/deps-packaging/cache-sftp index d05aa9c29..ddc023f4a 100755 --- a/deps-packaging/cache-sftp +++ b/deps-packaging/cache-sftp @@ -72,6 +72,20 @@ sftp_stdin() } +# Print sftp commands that remove the putdir upload dir tmp/$tmpdir. +# All are prefixed with '-', since the dir is gone after a successful +# rename. +cleanup_tmpdir_cmds() +{ + for f in $dirfiles + do + echo "-rm tmp/$tmpdir/`basename $f`" + done + echo "-rm tmp/$tmpdir/.DONE" + echo "-rmdir tmp/$tmpdir" +} + + print_usage() { ( @@ -187,9 +201,24 @@ main() echo " -rename tmp/$tmpdir $dirname " + + # Remove the upload dir if the rename failed, e.g. because + # another buildslave uploaded the package first + cleanup_tmpdir_cmds } | sftp_stdin retval=$? + + # sftp aborts the batch on the first failed command (e.g. put + # on a full disk), so clean up in a separate session + if [ $retval != 0 ] + then + { + echo "cd $REMOTE_CACHEDIR/dirs" + cleanup_tmpdir_cmds + } | sftp_stdin + fi + rm $tmpdir/.DONE ;; getfile)