diff --git a/Classes/GcsTarget.php b/Classes/GcsTarget.php index 6fc37b2..4d2b6f7 100644 --- a/Classes/GcsTarget.php +++ b/Classes/GcsTarget.php @@ -179,6 +179,12 @@ class GcsTarget implements TargetInterface */ protected $baseUriProvider; + /** + * + * @var array + */ + protected $publishedResourceSha1s = []; + /** * Constructor * @@ -463,6 +469,10 @@ public function getPublicStaticResourceUri($relativePathAndFilename): string */ public function publishResource(PersistentResource $resource, CollectionInterface $collection): void { + // Prevent multiple publish calls during the same request + if (in_array($resource->getSha1(), $this->publishedResourceSha1s)) { + return; + } $storage = $collection->getStorage(); if ($this->isOneBucketSetup($collection)) { $updated = false; @@ -521,6 +531,7 @@ public function publishResource(PersistentResource $resource, CollectionInterfac } $this->publishFile($sourceStream, $this->getRelativePublicationPathAndFilename($resource), $resource); } + $this->publishedResourceSha1s[] = $resource->getSha1(); } /**