diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2020-01-22 10:16:15 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2020-01-22 10:16:15 +0200 |
commit | 68be041dd11573aff08847748456040b9ef3f0b4 (patch) | |
tree | 62ef33804f0bafd8102415bbb6e31a528c35b560 | |
parent | 59376e36716be20a2a517231ef597b3687c45b0e (diff) | |
download | file-backup-68be041dd11573aff08847748456040b9ef3f0b4.tar.gz file-backup-68be041dd11573aff08847748456040b9ef3f0b4.tar.bz2 |
Bugfixes
* lib/File/BackupCopy.pm (backup_copy_internal): Clear unlink_on_destroy on
success.
* t/02auto.t: close FH to avoid spurious warnings
* t/TestBackup.pm: Fix incorrect range.
-rw-r--r-- | lib/File/BackupCopy.pm | 1 | ||||
-rw-r--r-- | t/02auto.t | 1 | ||||
-rw-r--r-- | t/TestBackup.pm | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/lib/File/BackupCopy.pm b/lib/File/BackupCopy.pm index b762e03..226e8ce 100644 --- a/lib/File/BackupCopy.pm +++ b/lib/File/BackupCopy.pm | |||
@@ -157,6 +157,7 @@ sub backup_copy_internal { | |||
157 | unless (rename($fh->filename, $backup_name)) { | 157 | unless (rename($fh->filename, $backup_name)) { |
158 | return _backup_copy_error("can't rename temporary file to $backup_name: $!"); | 158 | return _backup_copy_error("can't rename temporary file to $backup_name: $!"); |
159 | } | 159 | } |
160 | $fh->unlink_on_destroy(0); | ||
160 | return $backup_name; | 161 | return $backup_name; |
161 | } | 162 | } |
162 | 163 | ||
@@ -30,6 +30,7 @@ ok($name, File::Spec->catfile('subdir','a~')); | |||
30 | fileok('a', $name); | 30 | fileok('a', $name); |
31 | 31 | ||
32 | ok(open(FH, '>', File::Spec->catfile('subdir','a.~1~'))); | 32 | ok(open(FH, '>', File::Spec->catfile('subdir','a.~1~'))); |
33 | close FH; | ||
33 | $name = backup_copy_auto('a', dir => 'subdir'); | 34 | $name = backup_copy_auto('a', dir => 'subdir'); |
34 | ok($name, File::Spec->catfile('subdir','a.~2~')); | 35 | ok($name, File::Spec->catfile('subdir','a.~2~')); |
35 | fileok('a', $name); | 36 | fileok('a', $name); |
diff --git a/t/TestBackup.pm b/t/TestBackup.pm index 0679776..72e5925 100644 --- a/t/TestBackup.pm +++ b/t/TestBackup.pm | |||
@@ -26,7 +26,7 @@ sub makefile { | |||
26 | while ($size) { | 26 | while ($size) { |
27 | my $n = @pattern; | 27 | my $n = @pattern; |
28 | $n = $size if $n > $size; | 28 | $n = $size if $n > $size; |
29 | syswrite(FH, join('',@pattern[0..$n])) or | 29 | syswrite(FH, join('',@pattern[0..$n-1])) or |
30 | croak "write error creating $file: $!"; | 30 | croak "write error creating $file: $!"; |
31 | $size -= $n; | 31 | $size -= $n; |
32 | } | 32 | } |