From 5761e09dd23416b97a8e59e44f5efea5fd262834 Mon Sep 17 00:00:00 2001 From: Piotr M Date: Wed, 29 Mar 2017 10:27:02 +0200 Subject: [PATCH] Optimize put - dont fetch metadata for part file in checksuming --- .../Files/Storage/Wrapper/Checksum.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Storage/Wrapper/Checksum.php b/lib/private/Files/Storage/Wrapper/Checksum.php index a4d56e6c32a5..ed39642fd7bb 100644 --- a/lib/private/Files/Storage/Wrapper/Checksum.php +++ b/lib/private/Files/Storage/Wrapper/Checksum.php @@ -148,6 +148,22 @@ private static function getChecksumsInDbFormat($path) { return rtrim($checksumString); } + /** + * check if the file metadata should not be fetched + * NOTE: files with a '.part' extension are ignored as well! + * prevents unfinished put requests to fetch metadata which does not exists + * + * @param string $file + * @return boolean + */ + public static function isPartialFile($file) { + if (pathinfo($file, PATHINFO_EXTENSION) === 'part') { + return true; + } + + return false; + } + /** * @param string $path * @param string $data @@ -168,7 +184,11 @@ public function file_put_contents($path, $data) { * @return array */ public function getMetaData($path) { - $parentMetaData = $this->getWrapperStorage()->getMetaData($path); + // Check if it is partial file. Partial file metadata are only checksums + $parentMetaData = []; + if(!self::isPartialFile($path)) { + $parentMetaData = $this->getWrapperStorage()->getMetaData($path); + } $parentMetaData['checksum'] = self::getChecksumsInDbFormat($path); if (!isset($parentMetaData['mimetype'])) {