Skip to content

Commit

Permalink
Bugfix: recognize file content changes while filtering modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidgh83 committed May 27, 2024
1 parent 4a4478f commit 2c13ee7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Publiux/laravelcdn/Providers/AwsS3Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ private function getFilesAlreadyOnBucket($assets)
'Key' => $file['Key'],
'LastModified' => $file['LastModified']->getTimestamp(),
'Size' => intval($file['Size']),
'ETag' => str_replace('"', '', $file['ETag']),
];
$filesOnAWS->put($file['Key'], $a);
}
Expand All @@ -395,7 +396,9 @@ private function getFilesAlreadyOnBucket($assets)
$fileOnAWS = $filesOnAWS->get(str_replace('\\', '/', $file->getPathName()));

// select to upload files that are different in size AND last modified time.
return !$fileOnAWS || $file->getMTime() !== $fileOnAWS['LastModified'] && $file->getSize() !== $fileOnAWS['Size'];
return !$fileOnAWS
|| ($file->getMTime() !== $fileOnAWS['LastModified'] && $file->getSize() !== $fileOnAWS['Size'])
|| (md5_file($file->getPathname()) !== $fileOnAWS['ETag']);
});
}
}

0 comments on commit 2c13ee7

Please sign in to comment.