use absolute paths when resolving mount points
This commit is contained in:
parent
3437071cf1
commit
5bfff6c56e
|
@ -249,13 +249,3 @@ class OC_Files {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileCmp($a, $b) {
|
|
||||||
if ($a['type'] == 'dir' and $b['type'] != 'dir') {
|
|
||||||
return -1;
|
|
||||||
} elseif ($a['type'] != 'dir' and $b['type'] == 'dir') {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return strnatcasecmp($a['name'], $b['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ class Permissions {
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
static public function getMultiple($fileIds, $user) {
|
static public function getMultiple($fileIds, $user) {
|
||||||
|
if (count($fileIds) === 0) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
$params = $fileIds;
|
$params = $fileIds;
|
||||||
$params[] = $user;
|
$params[] = $user;
|
||||||
$inPart = implode(', ', array_fill(0, count($fileIds), '?'));
|
$inPart = implode(', ', array_fill(0, count($fileIds), '?'));
|
||||||
|
|
|
@ -110,6 +110,7 @@ class View {
|
||||||
*/
|
*/
|
||||||
public function getLocalFile($path) {
|
public function getLocalFile($path) {
|
||||||
$parent = substr($path, 0, strrpos($path, '/'));
|
$parent = substr($path, 0, strrpos($path, '/'));
|
||||||
|
$path = $this->getAbsolutePath($path);
|
||||||
list($storage, $internalPath) = Filesystem::resolvePath($path);
|
list($storage, $internalPath) = Filesystem::resolvePath($path);
|
||||||
if (Filesystem::isValidPath($parent) and $storage) {
|
if (Filesystem::isValidPath($parent) and $storage) {
|
||||||
return $storage->getLocalFile($internalPath);
|
return $storage->getLocalFile($internalPath);
|
||||||
|
@ -124,6 +125,7 @@ class View {
|
||||||
*/
|
*/
|
||||||
public function getLocalFolder($path) {
|
public function getLocalFolder($path) {
|
||||||
$parent = substr($path, 0, strrpos($path, '/'));
|
$parent = substr($path, 0, strrpos($path, '/'));
|
||||||
|
$path = $this->getAbsolutePath($path);
|
||||||
list($storage, $internalPath) = Filesystem::resolvePath($path);
|
list($storage, $internalPath) = Filesystem::resolvePath($path);
|
||||||
if (Filesystem::isValidPath($parent) and $storage) {
|
if (Filesystem::isValidPath($parent) and $storage) {
|
||||||
return $storage->getLocalFolder($internalPath);
|
return $storage->getLocalFolder($internalPath);
|
||||||
|
@ -334,8 +336,8 @@ class View {
|
||||||
$mp1 = $this->getMountPoint($path1 . $postFix1);
|
$mp1 = $this->getMountPoint($path1 . $postFix1);
|
||||||
$mp2 = $this->getMountPoint($path2 . $postFix2);
|
$mp2 = $this->getMountPoint($path2 . $postFix2);
|
||||||
if ($mp1 == $mp2) {
|
if ($mp1 == $mp2) {
|
||||||
list($storage, $internalPath1) = Filesystem::resolvePath($path1 . $postFix1);
|
list($storage, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
|
||||||
list(, $internalPath2) = Filesystem::resolvePath($path2 . $postFix2);
|
list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2);
|
||||||
if ($storage) {
|
if ($storage) {
|
||||||
$result = $storage->rename($internalPath1, $internalPath2);
|
$result = $storage->rename($internalPath1, $internalPath2);
|
||||||
} else {
|
} else {
|
||||||
|
@ -345,7 +347,7 @@ class View {
|
||||||
$source = $this->fopen($path1 . $postFix1, 'r');
|
$source = $this->fopen($path1 . $postFix1, 'r');
|
||||||
$target = $this->fopen($path2 . $postFix2, 'w');
|
$target = $this->fopen($path2 . $postFix2, 'w');
|
||||||
$count = \OC_Helper::streamCopy($source, $target);
|
$count = \OC_Helper::streamCopy($source, $target);
|
||||||
list($storage1, $internalPath1) = Filesystem::resolvePath($path1 . $postFix1);
|
list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
|
||||||
$storage1->unlink($internalPath1);
|
$storage1->unlink($internalPath1);
|
||||||
$result = $count > 0;
|
$result = $count > 0;
|
||||||
}
|
}
|
||||||
|
@ -417,8 +419,8 @@ class View {
|
||||||
$mp1 = $this->getMountPoint($path1 . $postFix1);
|
$mp1 = $this->getMountPoint($path1 . $postFix1);
|
||||||
$mp2 = $this->getMountPoint($path2 . $postFix2);
|
$mp2 = $this->getMountPoint($path2 . $postFix2);
|
||||||
if ($mp1 == $mp2) {
|
if ($mp1 == $mp2) {
|
||||||
list($storage, $internalPath1) = Filesystem::resolvePath($path1 . $postFix1);
|
list($storage, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
|
||||||
list(, $internalPath2) = Filesystem::resolvePath($path2 . $postFix2);
|
list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2);
|
||||||
if ($storage) {
|
if ($storage) {
|
||||||
$result = $storage->copy($internalPath1, $internalPath2);
|
$result = $storage->copy($internalPath1, $internalPath2);
|
||||||
} else {
|
} else {
|
||||||
|
@ -552,7 +554,7 @@ class View {
|
||||||
array(Filesystem::signal_param_path => $path)
|
array(Filesystem::signal_param_path => $path)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
list($storage, $internalPath) = Filesystem::resolvePath($path . $postFix);
|
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
|
||||||
if ($storage) {
|
if ($storage) {
|
||||||
$result = $storage->hash($type, $internalPath, $raw);
|
$result = $storage->hash($type, $internalPath, $raw);
|
||||||
$result = \OC_FileProxy::runPostProxies('hash', $absolutePath, $result);
|
$result = \OC_FileProxy::runPostProxies('hash', $absolutePath, $result);
|
||||||
|
@ -587,7 +589,7 @@ class View {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$run = $this->runHooks($hooks, $path);
|
$run = $this->runHooks($hooks, $path);
|
||||||
list($storage, $internalPath) = Filesystem::resolvePath($path . $postFix);
|
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
|
||||||
if ($run and $storage) {
|
if ($run and $storage) {
|
||||||
if (!is_null($extraParam)) {
|
if (!is_null($extraParam)) {
|
||||||
$result = $storage->$operation($internalPath, $extraParam);
|
$result = $storage->$operation($internalPath, $extraParam);
|
||||||
|
@ -747,8 +749,23 @@ class View {
|
||||||
$files[$i]['permissions'] = $permissions[$file['fileid']];
|
$files[$i]['permissions'] = $permissions[$file['fileid']];
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($files, "fileCmp");
|
if ($mimetype_filter) {
|
||||||
return $files;
|
foreach ($files as $file) {
|
||||||
|
if (strpos($mimetype_filter, '/')) {
|
||||||
|
if ($file['mimetype'] === $mimetype_filter) {
|
||||||
|
$result[] = $file;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($file['mimepart'] === $mimetype_filter) {
|
||||||
|
$result[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result = $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -534,7 +534,7 @@ class Share {
|
||||||
$backend = self::getBackend($itemType);
|
$backend = self::getBackend($itemType);
|
||||||
// Get filesystem root to add it to the file target and remove from the file source, match file_source with the file cache
|
// Get filesystem root to add it to the file target and remove from the file source, match file_source with the file cache
|
||||||
if ($itemType == 'file' || $itemType == 'folder') {
|
if ($itemType == 'file' || $itemType == 'folder') {
|
||||||
$root = \OC_Filesystem::getRoot();
|
$root = \OC\Files\Filesystem::getRoot();
|
||||||
$where = 'INNER JOIN `*PREFIX*fscache` ON `file_source` = `*PREFIX*fscache`.`id`';
|
$where = 'INNER JOIN `*PREFIX*fscache` ON `file_source` = `*PREFIX*fscache`.`id`';
|
||||||
if (!isset($item)) {
|
if (!isset($item)) {
|
||||||
$where .= ' WHERE `file_target` IS NOT NULL';
|
$where .= ' WHERE `file_target` IS NOT NULL';
|
||||||
|
@ -621,7 +621,7 @@ class Share {
|
||||||
} else {
|
} else {
|
||||||
if ($itemType == 'file' || $itemType == 'folder') {
|
if ($itemType == 'file' || $itemType == 'folder') {
|
||||||
$where .= ' `file_target` = ?';
|
$where .= ' `file_target` = ?';
|
||||||
$item = \OC_Filesystem::normalizePath($item);
|
$item = \OC\Files\Filesystem::normalizePath($item);
|
||||||
} else {
|
} else {
|
||||||
$where .= ' `item_target` = ?';
|
$where .= ' `item_target` = ?';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue