From 68be041dd11573aff08847748456040b9ef3f0b4 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 22 Jan 2020 10:16:15 +0200 Subject: 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. --- lib/File/BackupCopy.pm | 1 + t/02auto.t | 1 + t/TestBackup.pm | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) 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 { unless (rename($fh->filename, $backup_name)) { return _backup_copy_error("can't rename temporary file to $backup_name: $!"); } + $fh->unlink_on_destroy(0); return $backup_name; } diff --git a/t/02auto.t b/t/02auto.t index 0a01d84..61b24ed 100644 --- a/t/02auto.t +++ b/t/02auto.t @@ -30,6 +30,7 @@ ok($name, File::Spec->catfile('subdir','a~')); fileok('a', $name); ok(open(FH, '>', File::Spec->catfile('subdir','a.~1~'))); +close FH; $name = backup_copy_auto('a', dir => 'subdir'); ok($name, File::Spec->catfile('subdir','a.~2~')); 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 { while ($size) { my $n = @pattern; $n = $size if $n > $size; - syswrite(FH, join('',@pattern[0..$n])) or + syswrite(FH, join('',@pattern[0..$n-1])) or croak "write error creating $file: $!"; $size -= $n; } -- cgit v1.2.1