[pve-devel] [PATCH storage v4 05/12] Fix: backup: ctime was from stat not file name
Alwin Antreich
a.antreich at proxmox.com
Wed Apr 22 16:58:01 CEST 2020
The vzdump file was passed with the full path to the regex. That regex
captures the time from the file name, to calculate the epoch.
As the regex didn't match, the ctime from stat was taken instead. This
resulted in the ctime shown when the file was changed, not when the
backup was made.
Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
PVE/Storage/Plugin.pm | 3 ++-
test/list_volumes_test.pm | 16 ++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 71a83f7..9dde46e 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -942,7 +942,8 @@ my $get_subdir_files = sub {
next if $fn !~ m!/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!;
my $format = $2;
- $info = { volid => "$sid:backup/$1", format => $format };
+ $fn = $1;
+ $info = { volid => "$sid:backup/$fn", format => $format };
if ($fn =~ m!^vzdump\-(?:lxc|qemu)\-(?:[1-9][0-9]{2,8})\-(\d{4})_(\d{2})_(\d{2})\-(\d{2})_(\d{2})_(\d{2})\.${format}$!) {
my $epoch = timelocal($6, $5, $4, $3, $2-1, $1 - 1900);
diff --git a/test/list_volumes_test.pm b/test/list_volumes_test.pm
index c1428f2..ac0503e 100644
--- a/test/list_volumes_test.pm
+++ b/test/list_volumes_test.pm
@@ -129,7 +129,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585595500,
'format' => 'vma.gz',
'size' => DEFAULT_SIZE,
'vmid' => '16110',
@@ -137,7 +137,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585595565,
'format' => 'vma.lzo',
'size' => DEFAULT_SIZE,
'vmid' => '16110',
@@ -145,7 +145,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585595635,
'format' => 'vma',
'size' => DEFAULT_SIZE,
'vmid' => '16110',
@@ -189,7 +189,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585597170,
'format' => 'tar.lzo',
'size' => DEFAULT_SIZE,
'vmid' => '16112',
@@ -197,7 +197,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585597770,
'format' => 'tar.gz',
'size' => DEFAULT_SIZE,
'vmid' => '16112',
@@ -205,7 +205,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1585598370,
'format' => 'tgz',
'size' => DEFAULT_SIZE,
'vmid' => '16112',
@@ -347,7 +347,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1580756263,
'format' => 'tar.gz',
'size' => DEFAULT_SIZE,
'vmid' => '19253',
@@ -355,7 +355,7 @@ my @tests = (
},
{
'content' => 'backup',
- 'ctime' => DEFAULT_CTIME,
+ 'ctime' => 1548095359,
'format' => 'tar',
'size' => DEFAULT_SIZE,
'vmid' => '19254',
--
2.20.1
More information about the pve-devel
mailing list