From 162c933e022935500ccc8fa328d36eaa2bb5702c Mon Sep 17 00:00:00 2001 From: nadir Date: Tue, 9 Feb 2016 18:40:34 +0100 Subject: [PATCH] File version creation fix Avoiding creating a new file version when requesting a list of shared files --- lib/private/files/objectstore/eosutil.php | 11 +++++++++-- lib/private/share/share.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/private/files/objectstore/eosutil.php b/lib/private/files/objectstore/eosutil.php index 137ba1713efe..fec58368b3b4 100644 --- a/lib/private/files/objectstore/eosutil.php +++ b/lib/private/files/objectstore/eosutil.php @@ -773,7 +773,7 @@ public static function createVersion($eosPath) { // this function returns the fileid of the versions folder of a file // if versions folder does not exist, it will create it - public static function getVersionsFolderIDFromFileID($id) { + public static function getVersionsFolderIDFromFileID($id, $createVersion = true) { $meta = self::getFileById($id); // here we can receive the file to convert to version folder // or the version folder itself @@ -795,7 +795,14 @@ public static function getVersionsFolderIDFromFileID($id) { $versionInfo = \OC\Files\ObjectStore\EosUtil::getFileByEosPath($versionFolder); if(!$versionInfo) { - self::createVersion($meta['eospath']); + if($createVersion) + { + self::createVersion($meta['eospath']); + } + else + { + return null; + } } $versionInfo = \OC\Files\ObjectStore\EosUtil::getFileByEosPath($versionFolder); return $versionInfo['fileid']; diff --git a/lib/private/share/share.php b/lib/private/share/share.php index b13e6115757e..5048675786c5 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1399,7 +1399,7 @@ public static function getItems($itemType, $item = null, $shareType = null, $sha $includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) { /* HUGO if we receive itemType = file and an itemSource then we need to point to the versions folder */ if($itemType === 'file' && is_numeric($item)) { - $item = \OC\Files\ObjectStore\EosUtil::getVersionsFolderIDFromFileID($item); + $item = \OC\Files\ObjectStore\EosUtil::getVersionsFolderIDFromFileID($item, false); } if (!self::isEnabled()) { return array();