diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2015-03-25 20:15:49 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-03-25 20:15:49 +0100 |
commit | bc180068995181b4c633e5082dc2568431461623 (patch) | |
tree | accaab0df2422a1d1d414e3953bb3c80e91aaee3 /cli | |
parent | e7529b3c3aafb051bea1a290221d3593920fe014 (diff) |
Delete temp files upon move failure.
Diffstat (limited to 'cli')
-rwxr-xr-x | cli/icevault | 8 |
1 files changed, 6 insertions, 2 deletions
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); } } |