Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ function(ReplaceAssetEvent $event) {
$oldFilename = $asset->getFilename();
$newFilename = $event->filename;

// when replacing asset with another one with the same filename, invalidate the cdn path for the original file too
// see https://github.com/craftcms/aws-s3/issues/184 for details
// when replacing an asset with another one with the same filename, invalidate the CDN path for the original file too
// see https://github.com/craftcms/aws-s3/issues/184 and https://github.com/craftcms/aws-s3/issues/195 for details
if ($oldFilename === $newFilename) {
$fs->invalidateCdnPath($asset->getPath());
$folderPath = trim($asset->getFolder()->path, '/');
$oldPath = $folderPath !== ''
? $folderPath . '/' . $oldFilename
: $oldFilename;

$fs->invalidateCdnPath($oldPath);
}
}
);
Expand Down
Loading