From 78c76b2a0eb10fa514bbae71f93f351ee58dacd3 Mon Sep 17 00:00:00 2001 From: Robert Lemke Date: Tue, 19 Feb 2019 18:30:15 +0100 Subject: [PATCH] Introduce --startSha1 option --- Classes/Command/GcsCommandController.php | 27 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Classes/Command/GcsCommandController.php b/Classes/Command/GcsCommandController.php index bd7833c..487e2ea 100644 --- a/Classes/Command/GcsCommandController.php +++ b/Classes/Command/GcsCommandController.php @@ -133,9 +133,13 @@ public function republishCommand(string $collection = 'persistent'): void * This command can be used for migrating from a two-bucket to a one-bucket setup, where storage and target are using * the same bucket. * + * The resources are processed in alphabetical order of their SHA1 content hashes. That allows you to resume updates + * at a specific resource (using the --startSha1 option) in case a large update was interrupted. + * * @param string $collection Name of the collection to publish + * @param string|null $startSha1 If specified, updates are starting at this SHA1 in alphabetical order */ - public function updateResourceMetadataCommand(string $collection = 'persistent'): void + public function updateResourceMetadataCommand(string $collection = 'persistent', string $startSha1 = null): void { $collectionName = $collection; $collection = $this->resourceManager->getCollection($collection); @@ -169,12 +173,21 @@ public function updateResourceMetadataCommand(string $collection = 'persistent') $targetBucket = $storageClient->bucket($target->getBucketName()); $targetKeyPrefix = $target->getKeyPrefix(); - $queryResult = $entityManager->getConnection()->executeQuery( - 'SELECT sha1, filename, mediatype FROM neos_flow_resourcemanagement_persistentresource AS r WHERE collectionname = :collectionName ORDER BY sha1', - [ - 'collectionName' => $collectionName - ] - ); + + if ($startSha1 === null) { + $queryResult = $entityManager->getConnection()->executeQuery( + 'SELECT sha1, filename, mediatype FROM neos_flow_resourcemanagement_persistentresource AS r WHERE collectionname = :collectionName ORDER BY sha1', + ['collectionName' => $collectionName] + ); + } else { + $queryResult = $entityManager->getConnection()->executeQuery( + 'SELECT sha1, filename, mediatype FROM neos_flow_resourcemanagement_persistentresource AS r WHERE collectionname = :collectionName AND sha1 > :startSha1 ORDER BY sha1', + [ + 'collectionName' => $collectionName, + 'startSha1' => $startSha1 + ] + ); + } try { $previousSha1 = null;