Skip to content

Commit

Permalink
Removal of deprecated functions getMd5() and setMd5()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuiphuis committed Dec 16, 2020
1 parent 52d6bd4 commit 3a06376
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Classes/S3Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ public function importResource($source, $collectionName)
public function importResourceFromContent($content, $collectionName)
{
$sha1Hash = sha1($content);
$md5Hash = md5($content);
//$md5Hash = md5($content);
$filename = $sha1Hash;

$resource = new PersistentResource();
$resource->setFilename($filename);
$resource->setFileSize(strlen($content));
$resource->setCollectionName($collectionName);
$resource->setSha1($sha1Hash);
$resource->setMd5($md5Hash);
//$resource->setMd5($md5Hash);

$this->s3Client->putObject(array(
'Bucket' => $this->bucketName,
Expand Down Expand Up @@ -253,14 +253,14 @@ public function importUploadedResource(array $uploadInfo, $collectionName)
}

$sha1Hash = sha1_file($newSourcePathAndFilename);
$md5Hash = md5_file($newSourcePathAndFilename);
//$md5Hash = md5_file($newSourcePathAndFilename);

$resource = new PersistentResource();
$resource->setFilename($originalFilename);
$resource->setCollectionName($collectionName);
$resource->setFileSize(filesize($newSourcePathAndFilename));
$resource->setSha1($sha1Hash);
$resource->setMd5($md5Hash);
//$resource->setMd5($md5Hash);

$this->s3Client->putObject(array(
'Bucket' => $this->bucketName,
Expand Down Expand Up @@ -388,14 +388,14 @@ public function getObjectsByCollection(CollectionInterface $collection)
protected function importTemporaryFile($temporaryPathAndFilename, $collectionName)
{
$sha1Hash = sha1_file($temporaryPathAndFilename);
$md5Hash = md5_file($temporaryPathAndFilename);
//$md5Hash = md5_file($temporaryPathAndFilename);
$objectName = $this->keyPrefix . $sha1Hash;

$resource = new PersistentResource();
$resource->setFileSize(filesize($temporaryPathAndFilename));
$resource->setCollectionName($collectionName);
$resource->setSha1($sha1Hash);
$resource->setMd5($md5Hash);
//$resource->setMd5($md5Hash);

try {
$this->s3Client->headObject([
Expand All @@ -418,7 +418,7 @@ protected function importTemporaryFile($temporaryPathAndFilename, $collectionNam
'ContentType' => $resource->getMediaType(),
'Key' => $objectName
]);
$this->systemLogger->info(sprintf('Successfully imported resource as object "%s" into bucket "%s" with MD5 hash "%s"', $objectName, $this->bucketName, $resource->getMd5() ?: 'unknown'));
$this->systemLogger->info(sprintf('Successfully imported resource as object "%s" into bucket "%s" with SHA1 hash "%s"', $objectName, $this->bucketName, $resource->getSha1() ?: 'unknown'));
} else {
$this->systemLogger->info(sprintf('Did not import resource as object "%s" into bucket "%s" because that object already existed.', $objectName, $this->bucketName));
}
Expand Down
12 changes: 6 additions & 6 deletions Classes/S3Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function publishCollection(CollectionInterface $collection, callable $cal
/** @var \Neos\Flow\ResourceManagement\Storage\StorageObject $object */
$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));
$this->systemLogger->debug(sprintf('The resource object "%s" (SHA1: %s) has already been published to bucket "%s", no need to re-publish', $objectName, $object->getSha1() ?: 'unknown', $this->bucketName));
unset($potentiallyObsoleteObjects[$objectName]);
} else {
$options = array(
Expand All @@ -224,7 +224,7 @@ public function publishCollection(CollectionInterface $collection, callable $cal
);
try {
$this->s3Client->copyObject($options);
$this->systemLogger->debug(sprintf('Successfully copied resource as object "%s" (MD5: %s) from bucket "%s" to bucket "%s"', $objectName, $object->getMd5() ?: 'unknown', $storageBucketName, $this->bucketName));
$this->systemLogger->debug(sprintf('Successfully copied resource as object "%s" (SHA1: %s) from bucket "%s" to bucket "%s"', $objectName, $object->getSha1() ?: 'unknown', $storageBucketName, $this->bucketName));
} catch (S3Exception $e) {
$message = sprintf('Could not copy resource with SHA1 hash %s of collection %s from bucket %s to %s: %s', $object->getSha1(), $collection->getName(), $storageBucketName, $this->bucketName, $e->getMessage());
$this->systemLogger->critical($e);
Expand Down Expand Up @@ -292,7 +292,7 @@ public function publishResource(PersistentResource $resource, CollectionInterfac
'Key' => $objectName
);
$this->s3Client->copyObject($options);
$this->systemLogger->debug(sprintf('Successfully published resource as object "%s" (MD5: %s) by copying from bucket "%s" to bucket "%s"', $objectName, $resource->getMd5() ?: 'unknown', $storage->getBucketName(), $this->bucketName));
$this->systemLogger->debug(sprintf('Successfully published resource as object "%s" (SHA1: %s) by copying from bucket "%s" to bucket "%s"', $objectName, $resource->getSha1() ?: 'unknown', $storage->getBucketName(), $this->bucketName));
} catch (S3Exception $e) {
$message = sprintf('Could not publish resource with SHA1 hash %s of collection %s (source object: %s) through "CopyObject" because the S3 client reported an error: %s', $resource->getSha1(), $collection->getName(), $sourceObjectArn, $e->getMessage());
$this->systemLogger->critical($e);
Expand Down Expand Up @@ -323,7 +323,7 @@ public function unpublishResource(PersistentResource $resource)
'Bucket' => $this->bucketName,
'Key' => $objectName
));
$this->systemLogger->debug(sprintf('Successfully unpublished resource as object "%s" (MD5: %s) from bucket "%s"', $objectName, $resource->getMd5() ?: 'unknown', $this->bucketName));
$this->systemLogger->debug(sprintf('Successfully unpublished resource as object "%s" (SHA1: %s) from bucket "%s"', $objectName, $resource->getSha1() ?: 'unknown', $this->bucketName));
} catch (\Exception $e) {
}
}
Expand Down Expand Up @@ -375,9 +375,9 @@ protected function publishFile($sourceStream, $relativeTargetPathAndFilename, Re

try {
$this->s3Client->upload($this->bucketName, $objectName, $sourceStream, 'public-read', $options);
$this->systemLogger->debug(sprintf('Successfully published resource as object "%s" in bucket "%s" with MD5 hash "%s"', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown'));
$this->systemLogger->debug(sprintf('Successfully published resource as object "%s" in bucket "%s" with SHA1 hash "%s"', $objectName, $this->bucketName, $metaData->getSha1() ?: 'unknown'));
} catch (\Exception $e) {
$this->systemLogger->debug(sprintf('Failed publishing resource as object "%s" in bucket "%s" with MD5 hash "%s": %s', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown', $e->getMessage()));
$this->systemLogger->debug(sprintf('Failed publishing resource as object "%s" in bucket "%s" with SHA1 hash "%s": %s', $objectName, $this->bucketName, $metaData->getSha1() ?: 'unknown', $e->getMessage()));
if (is_resource($sourceStream)) {
fclose($sourceStream);
}
Expand Down

0 comments on commit 3a06376

Please sign in to comment.