Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r--lib/private/files/view.php57
1 files changed, 36 insertions, 21 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index d97544b865e..2dbbf5b88c9 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -48,7 +48,7 @@ class View {
* change the root to a fake root
*
* @param string $fakeRoot
- * @return bool
+ * @return boolean|null
*/
public function chroot($fakeRoot) {
if (!$fakeRoot == '') {
@@ -352,6 +352,9 @@ class View {
return $this->basicOperation('unlink', $path, array('delete'));
}
+ /**
+ * @param string $directory
+ */
public function deleteAll($directory, $empty = false) {
return $this->rmdir($directory);
}
@@ -410,7 +413,7 @@ class View {
$result = $this->copy($path1, $path2);
if ($result === true) {
list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
- $result = $storage1->deleteAll($internalPath1);
+ $result = $storage1->unlink($internalPath1);
}
} else {
$source = $this->fopen($path1 . $postFix1, 'r');
@@ -531,6 +534,8 @@ class View {
$source = $this->fopen($path1 . $postFix1, 'r');
$target = $this->fopen($path2 . $postFix2, 'w');
list($count, $result) = \OC_Helper::streamCopy($source, $target);
+ fclose($source);
+ fclose($target);
}
}
if ($this->shouldEmitHooks() && $result !== false) {
@@ -735,6 +740,9 @@ class View {
return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
}
+ /**
+ * @param string $path
+ */
private function runHooks($hooks, $path, $post = false) {
$path = $this->getHookPath($path);
$prefix = ($post) ? 'post_' : '';
@@ -781,14 +789,7 @@ class View {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo | false
*/
public function getFileInfo($path, $includeMountPoints = true) {
$data = array();
@@ -841,10 +842,13 @@ class View {
$data['permissions'] = $permissions;
}
}
+ if (!$data) {
+ return false;
+ }
$data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
- return $data;
+ return new FileInfo($path, $storage, $internalPath, $data);
}
/**
@@ -852,7 +856,7 @@ class View {
*
* @param string $directory path under datadirectory
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
- * @return array
+ * @return FileInfo[]
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
$result = array();
@@ -878,8 +882,13 @@ class View {
$watcher->checkUpdate($internalPath);
}
- $files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
- $permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user);
+ $folderId = $cache->getId($internalPath);
+ $files = array();
+ $contents = $cache->getFolderContents($internalPath, $folderId); //TODO: mimetype_filter
+ foreach ($contents as $content) {
+ $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
+ }
+ $permissions = $permissionsCache->getDirectoryPermissions($folderId, $user);
$ids = array();
foreach ($files as $i => $file) {
@@ -936,7 +945,7 @@ class View {
break;
}
}
- $files[] = $rootEntry;
+ $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry);
}
}
}
@@ -958,6 +967,7 @@ class View {
$result = $files;
}
}
+
return $result;
}
@@ -965,12 +975,15 @@ class View {
* change file metadata
*
* @param string $path
- * @param array $data
+ * @param array | \OCP\Files\FileInfo $data
* @return int
*
* returns the fileid of the updated file
*/
public function putFileInfo($path, $data) {
+ if ($data instanceof FileInfo) {
+ $data = $data->getData();
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -995,7 +1008,7 @@ class View {
* search for files with the name matching $query
*
* @param string $query
- * @return array
+ * @return FileInfo[]
*/
public function search($query) {
return $this->searchCommon('%' . $query . '%', 'search');
@@ -1005,7 +1018,7 @@ class View {
* search for files by mimetype
*
* @param string $mimetype
- * @return array
+ * @return FileInfo[]
*/
public function searchByMime($mimetype) {
return $this->searchCommon($mimetype, 'searchByMime');
@@ -1014,7 +1027,7 @@ class View {
/**
* @param string $query
* @param string $method
- * @return array
+ * @return FileInfo[]
*/
private function searchCommon($query, $method) {
$files = array();
@@ -1028,8 +1041,9 @@ class View {
$results = $cache->$method($query);
foreach ($results as $result) {
if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
+ $internalPath = $result['path'];
$result['path'] = substr($mountPoint . $result['path'], $rootLength);
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
@@ -1043,8 +1057,9 @@ class View {
$results = $cache->$method($query);
if ($results) {
foreach ($results as $result) {
+ $internalPath = $result['path'];
$result['path'] = $relativeMountPoint . $result['path'];
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
}