Merge branch 'filesystem' into filesystem-etags
This commit is contained in:
commit
6f049d0889
10 changed files with 76 additions and 39 deletions
|
@ -41,7 +41,7 @@ class Google extends \OC\Files\Storage\Common {
|
|||
) {
|
||||
$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
|
||||
$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
|
||||
$this->id = 'google::' . $consumer_key . $consumer_secret;
|
||||
$this->id = 'google::' . $params['token'];
|
||||
$this->consumer = new \OAuthConsumer($consumer_key, $consumer_secret);
|
||||
$this->oauth_token = new \OAuthToken($params['token'], $params['token_secret']);
|
||||
$this->sig_method = new \OAuthSignatureMethod_HMAC_SHA1();
|
||||
|
|
|
@ -79,6 +79,8 @@ class Shared_Cache extends Cache {
|
|||
$data['size'] = (int)$data['size'];
|
||||
$data['mtime'] = (int)$data['mtime'];
|
||||
$data['encrypted'] = (bool)$data['encrypted'];
|
||||
$data['mimetype'] = $this->getMimetype($data['mimetype']);
|
||||
$data['mimepart'] = $this->getMimetype($data['mimepart']);
|
||||
return $data;
|
||||
}
|
||||
return false;
|
||||
|
@ -92,7 +94,12 @@ class Shared_Cache extends Cache {
|
|||
*/
|
||||
public function getFolderContents($folder) {
|
||||
if ($folder == '') {
|
||||
return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS);
|
||||
$files = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS);
|
||||
foreach ($files as &$file) {
|
||||
$file['mimetype'] = $this->getMimetype($file['mimetype']);
|
||||
$file['mimepart'] = $this->getMimetype($file['mimepart']);
|
||||
}
|
||||
return $files;
|
||||
} else {
|
||||
if ($cache = $this->getSourceCache($folder)) {
|
||||
return $cache->getFolderContents($this->files[$folder]);
|
||||
|
@ -129,6 +136,19 @@ class Shared_Cache extends Cache {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a file is available in the cache
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function inCache($file) {
|
||||
if ($file == '') {
|
||||
return true;
|
||||
}
|
||||
return parent::inCache($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove a file or folder from the cache
|
||||
*
|
||||
|
@ -176,7 +196,7 @@ class Shared_Cache extends Cache {
|
|||
if ($cache = $this->getSourceCache($file)) {
|
||||
return $cache->getStatus($this->files[$file]);
|
||||
}
|
||||
return false;
|
||||
return self::NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
namespace OC\Files\Cache;
|
||||
|
||||
class Shared_Permissions {
|
||||
class Shared_Permissions extends Permissions {
|
||||
|
||||
/**
|
||||
* get the permissions for a single file
|
||||
|
@ -29,11 +29,11 @@ class Shared_Permissions {
|
|||
* @param string $user
|
||||
* @return int (-1 if file no permissions set)
|
||||
*/
|
||||
static public function get($fileId, $user) {
|
||||
public function get($fileId, $user) {
|
||||
if ($fileId == -1) {
|
||||
return \OCP\PERMISSION_READ;
|
||||
}
|
||||
$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
|
||||
$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, null, true);
|
||||
if ($source) {
|
||||
return $source['permissions'];
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ class Shared_Permissions {
|
|||
* @param string $user
|
||||
* @param int $permissions
|
||||
*/
|
||||
static public function set($fileId, $user, $permissions) {
|
||||
public function set($fileId, $user, $permissions) {
|
||||
// Not a valid action for Shared Permissions
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class Shared_Permissions {
|
|||
* @param string $user
|
||||
* @return int[]
|
||||
*/
|
||||
static public function getMultiple($fileIds, $user) {
|
||||
public function getMultiple($fileIds, $user) {
|
||||
if (count($fileIds) === 0) {
|
||||
return array();
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ class Shared_Permissions {
|
|||
* @param int $fileId
|
||||
* @param string $user
|
||||
*/
|
||||
static public function remove($fileId, $user) {
|
||||
public function remove($fileId, $user) {
|
||||
// Not a valid action for Shared Permissions
|
||||
}
|
||||
|
||||
static public function removeMultiple($fileIds, $user) {
|
||||
public function removeMultiple($fileIds, $user) {
|
||||
// Not a valid action for Shared Permissions
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
|||
}
|
||||
|
||||
public static function getSource($target) {
|
||||
if ($target == '') {
|
||||
return false;
|
||||
}
|
||||
$target = '/'.$target;
|
||||
$target = rtrim($target, '/');
|
||||
$pos = strpos($target, '/', 1);
|
||||
|
|
|
@ -24,6 +24,13 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
|
|||
public function getChildren($itemSource) {
|
||||
$children = array();
|
||||
$parents = array($itemSource);
|
||||
$query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
|
||||
$result = $query->execute(array('httpd/unix-directory'));
|
||||
if ($row = $result->fetchRow()) {
|
||||
$mimetype = $row['id'];
|
||||
} else {
|
||||
$mimetype = -1;
|
||||
}
|
||||
while (!empty($parents)) {
|
||||
$parents = "'".implode("','", $parents)."'";
|
||||
$query = OC_DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache` WHERE `parent` IN ('.$parents.')');
|
||||
|
@ -32,8 +39,8 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
|
|||
while ($file = $result->fetchRow()) {
|
||||
$children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
|
||||
// If a child folder is found look inside it
|
||||
if ($file['mimetype'] == 'httpd/unix-directory') {
|
||||
$parents[] = $file['id'];
|
||||
if ($file['mimetype'] == $mimetype) {
|
||||
$parents[] = $file['fileid'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,12 +408,6 @@ class Shared extends \OC\Files\Storage\Common {
|
|||
}
|
||||
|
||||
public function getScanner($path = '') {
|
||||
if ($path != '' && ($source = $this->getSourcePath($path))) {
|
||||
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
|
||||
if ($storage) {
|
||||
return $storage->getScanner($internalPath);
|
||||
}
|
||||
}
|
||||
return new \OC\Files\Cache\Scanner($this);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
<type>text</type>
|
||||
<default></default>
|
||||
<notnull>true</notnull>
|
||||
<length>64</length>
|
||||
<length>255</length>
|
||||
</field>
|
||||
|
||||
<index>
|
||||
|
|
|
@ -765,8 +765,17 @@ class View {
|
|||
$subStorage = Filesystem::getStorage($mountPoint);
|
||||
if ($subStorage) {
|
||||
$subCache = $subStorage->getCache('');
|
||||
$rootEntry = $subCache->get('');
|
||||
|
||||
if ($subCache->getStatus('') === Cache\Cache::NOT_FOUND) {
|
||||
$subScanner = $subStorage->getScanner('');
|
||||
$subScanner->scanFile('');
|
||||
} else {
|
||||
$subWatcher = $subStorage->getWatcher('');
|
||||
$subWatcher->checkUpdate('');
|
||||
}
|
||||
|
||||
$rootEntry = $subCache->get('');
|
||||
if ($rootEntry) {
|
||||
$relativePath = trim(substr($mountPoint, $dirLength), '/');
|
||||
if ($pos = strpos($relativePath, '/')) { //mountpoint inside subfolder add size to the correct folder
|
||||
$entryName = substr($relativePath, 0, $pos);
|
||||
|
@ -784,11 +793,12 @@ class View {
|
|||
$permissions = $subStorage->getPermissions($rootEntry['path']);
|
||||
$subPermissionsCache->set($rootEntry['fileid'], $user, $permissions);
|
||||
}
|
||||
$rootEntry['permissions'] = $subPermissionsCache;
|
||||
$rootEntry['permissions'] = $permissions;
|
||||
$files[] = $rootEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mimetype_filter) {
|
||||
foreach ($files as $file) {
|
||||
|
|
|
@ -756,7 +756,7 @@ class Share {
|
|||
$collectionItems = array();
|
||||
foreach ($items as &$row) {
|
||||
// Return only the item instead of a 2-dimensional array
|
||||
if ($limit == 1 && $row['item_type'] == $itemType && $row[$column] == $item) {
|
||||
if ($limit == 1 && $row[$column] == $item && ($row['item_type'] == $itemType || $itemType == 'file')) {
|
||||
if ($format == self::FORMAT_NONE) {
|
||||
return $row;
|
||||
} else {
|
||||
|
@ -823,6 +823,9 @@ class Share {
|
|||
if (!empty($collectionItems)) {
|
||||
$items = array_merge($items, $collectionItems);
|
||||
}
|
||||
if (empty($items) && $limit == 1) {
|
||||
return false;
|
||||
}
|
||||
if ($format == self::FORMAT_NONE) {
|
||||
return $items;
|
||||
} else if ($format == self::FORMAT_STATUSES) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class OC_Util {
|
|||
*/
|
||||
public static function getVersion() {
|
||||
// hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user
|
||||
return array(4,91,05);
|
||||
return array(4,91,06);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue