Skip to content

Commit

Permalink
Merge pull request #33 from Sebobo/patch-1
Browse files Browse the repository at this point in the history
BUGFIX: Prevent copying same file multiple times
  • Loading branch information
kitsunet authored Jun 30, 2020
2 parents 76daf3f + cf8495a commit 1d3bf1c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/S3Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down

0 comments on commit 1d3bf1c

Please sign in to comment.