From cf8495a28e1fc72144b488d1a5b9b014c7be6cda Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Tue, 30 Jun 2020 12:28:40 +0200 Subject: [PATCH] BUGFIX: Prevent copying same file multiple times When a file exists multiple times as variant it was copied n-1 times because the first time it was matched against the known objects the known object info was deleted. Further checks then initiated the copy process again. --- Classes/S3Target.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Classes/S3Target.php b/Classes/S3Target.php index 8ae9ee2..5628853 100644 --- a/Classes/S3Target.php +++ b/Classes/S3Target.php @@ -205,7 +205,7 @@ public function publishCollection(CollectionInterface $collection, callable $cal $objectName = $this->keyPrefix . $this->getRelativePublicationPathAndFilename($object); if (array_key_exists($objectName, $potentiallyObsoleteObjects)) { $this->systemLogger->debug(sprintf('The resource object "%s" (MD5: %s) has already been published to bucket "%s", no need to re-publish', $objectName, $object->getMd5() ?: 'unknown', $this->bucketName)); - unset($potentiallyObsoleteObjects[$objectName]); + $potentiallyObsoleteObjects[$objectName] = false; } else { $options = array( 'ACL' => 'public-read', @@ -230,11 +230,14 @@ public function publishCollection(CollectionInterface $collection, callable $cal /** @var \Neos\Flow\ResourceManagement\Storage\StorageObject $object */ $this->publishFile($object->getStream(), $this->getRelativePublicationPathAndFilename($object), $object); $objectName = $this->keyPrefix . $this->getRelativePublicationPathAndFilename($object); - unset($potentiallyObsoleteObjects[$objectName]); + $potentiallyObsoleteObjects[$objectName] = false; } } foreach (array_keys($potentiallyObsoleteObjects) as $relativePathAndFilename) { + if (!$potentiallyObsoleteObjects[$relativePathAndFilename]) { + continue; + } $this->systemLogger->debug(sprintf('Deleted obsolete resource "%s" from bucket "%s"', $relativePathAndFilename, $this->bucketName)); $this->s3Client->deleteObject(array( 'Bucket' => $this->bucketName,