1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Make buildPutDiffers() work with empty files.

If the file was empty the timestamp was updated.  If the file is empty and there is no content then file should not be saved.
This commit is contained in:
David Steele
2019-12-10 13:02:36 -05:00
parent 800d2972b0
commit d7d663c2b9
+8 -3
View File
@@ -32,22 +32,27 @@ sub buildPutDiffers
{ {
my $oStorage = shift; my $oStorage = shift;
my $strFile = shift; my $strFile = shift;
my $strContents = shift; my $strContentNew = shift;
# Attempt to load the file # Attempt to load the file
my $bSave = true; my $bSave = true;
my $oFile = $oStorage->openRead($strFile, {bIgnoreMissing => true}); my $oFile = $oStorage->openRead($strFile, {bIgnoreMissing => true});
# If file was found see if the content is the same # If file was found see if the content is the same
if (defined($oFile) && ${$oStorage->get($oFile)} eq $strContents) if (defined($oFile))
{
my $strContentFile = ${$oStorage->get($oFile)};
if ((defined($strContentFile) ? $strContentFile : '') eq (defined($strContentNew) ? $strContentNew : ''))
{ {
$bSave = false; $bSave = false;
} }
}
# Save if the contents are different or missing # Save if the contents are different or missing
if ($bSave) if ($bSave)
{ {
$oStorage->put($oStorage->openWrite($strFile, {bPathCreate => true}), $strContents); $oStorage->put($oStorage->openWrite($strFile, {bPathCreate => true}), $strContentNew);
} }
# Was the file saved? # Was the file saved?