From 8dd116be9e692902721c126852d2173e78ab0aef Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Fri, 31 Jul 2015 14:06:35 +0200 Subject: [PATCH] Fix problem when creating shares that point to a version file instead of version folder --- lib/private/files/objectstore/eosutil.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/files/objectstore/eosutil.php b/lib/private/files/objectstore/eosutil.php index b63495670c9e..75e5d890fd3b 100644 --- a/lib/private/files/objectstore/eosutil.php +++ b/lib/private/files/objectstore/eosutil.php @@ -727,12 +727,19 @@ public static function getVersionsFolderIDFromFileID($id) { // so we need to check carefuly $eos_version_regex = \OCP\Config::getSystemValue("eos_version_regex"); // if file is already version folder we return that inode - if (preg_match("|".$eos_version_regex."|", $meta["eospath"]) ) { + if (preg_match("|".$eos_version_regex."|", basename($meta["eospath"])) ) { return $meta['fileid']; } else { $dirname = dirname($meta['eospath']); $basename = basename($meta['eospath']); + // We need to handle the case where the file is already a version. + // In that case the version folder is the parent. $versionFolder = $dirname . "/.sys.v#." . $basename; + if (preg_match("|".$eos_version_regex."|", $dirname) ) { + $versionFolder = $dirname; + } + + $versionInfo = \OC\Files\ObjectStore\EosUtil::getFileByEosPath($versionFolder); if(!$versionInfo) { self::createVersion($meta['eospath']);