Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions deps-packaging/cache-sftp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
(
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# another buildslave uploaded the package first
# another build host 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)
Expand Down
Loading