From bc180068995181b4c633e5082dc2568431461623 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 25 Mar 2015 20:15:49 +0100 Subject: Delete temp files upon move failure. --- cli/icevault | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/icevault b/cli/icevault index eb8c343..e0c2757 100755 --- a/cli/icevault +++ b/cli/icevault @@ -398,7 +398,11 @@ sub saveIdentityFile($$) { my $parent_dir = $filename =~ s/\/[^\/]+$//r; File::Path::make_path($parent_dir) unless -d $parent_dir; # create parent directories recursively - File::Copy::move($outfh->filename, $filename) or error "Can't move C<%s>: %s", $outfh->filename, $!; + unless (File::Copy::move($outfh->filename, $filename)){ + my $r = $!; + unlink $outfh->filename; + error "Can't move C<%s>: %s", $outfh->filename, $r; + } # TODO: git add $filename; git commit } @@ -854,7 +858,7 @@ elsif ($command eq 'edit') { } else { myprintf "Saving user changes for identity C<%s>", $id; - saveIdentityFile( $fh->filename, $filename); + saveIdentityFile($fh->filename, $filename); } } -- cgit v1.2.3