Skip to content

Commit

Permalink
File version creation fix
Browse files Browse the repository at this point in the history
Avoiding creating a new file version when requesting a list of shared
files
  • Loading branch information
nadir committed Feb 9, 2016
1 parent 6dd753a commit 162c933
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/private/files/objectstore/eosutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion lib/private/share/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 162c933

Please sign in to comment.