summaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-10-30 13:41:10 +0100
committerRobin Appelman <icewind@owncloud.com>2013-10-30 13:41:10 +0100
commitc9f3f2874f3136342965a1d255d030de87725519 (patch)
tree8a9ca523992d2b461d71c3483bd1e0b31dae4f7a /lib/private/files
parent654b0daf0145b216d81347325b17cf522a49ec81 (diff)
parent4c964cbbbe2b92d6220410cda5e7905e529fc713 (diff)
downloadnextcloud-server-c9f3f2874f3136342965a1d255d030de87725519.tar.gz
nextcloud-server-c9f3f2874f3136342965a1d255d030de87725519.zip
Merge branch 'master' into update-parent-storage-mtime
Conflicts: lib/private/files/cache/updater.php
Diffstat (limited to 'lib/private/files')
-rw-r--r--lib/private/files/cache/cache.php4
-rw-r--r--lib/private/files/cache/updater.php51
-rw-r--r--lib/private/files/type/detection.php8
3 files changed, 49 insertions, 14 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index fc2d965d7f9..c1e5b34c8aa 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -64,6 +64,10 @@ class Cache {
* @return int
*/
public function getMimetypeId($mime) {
+ if (empty($mime)) {
+ // Can not insert empty string into Oracle NOT NULL column.
+ $mime = 'application/octet-stream';
+ }
if (empty(self::$mimetypeIds)) {
$this->loadMimetypes();
}
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index b491b60b0d0..da223567001 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -100,6 +100,24 @@ class Updater {
}
/**
+ * @brief get file owner and path
+ * @param string $filename
+ * @return array with the oweners uid and the owners path
+ */
+ private static function getUidAndFilename($filename) {
+
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+
+ if ($uid != \OCP\User::getUser()) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/' . $uid . '/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, '/files/' . $filename);
+ }
+
+ /**
* Update the mtime and ETag of all parent folders
*
* @param string $path
@@ -107,23 +125,32 @@ class Updater {
*/
static public function correctFolder($path, $time) {
if ($path !== '' && $path !== '/') {
- $parent = dirname($path);
- if ($parent === '.' || $parent === '\\') {
- $parent = '';
- }
+
+ list($owner, $realPath) = self::getUidAndFilename(dirname($path));
+
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
- list($storage, $internalPath) = self::resolvePath($parent);
- if ($storage) {
- $cache = $storage->getCache();
- $id = $cache->getId($internalPath);
- if ($id !== -1) {
- $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
- self::correctFolder($parent, $time);
+ $view = new \OC\Files\View('/' . $owner);
+
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
+
+ while ($id !== -1) {
+ $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
+ if ($realPath !== '') {
+ $realPath = dirname($realPath);
+ if($realPath === '/') {
+ $realPath = "";
+ }
+ // check storage for parent in case we change the storage in this step
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
} else {
- Util::writeLog('core', 'Path not in cache: ' . $internalPath, Util::ERROR);
+ $id = -1;
}
}
}
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index 242a81cb5a4..d7cc9ebbf4e 100644
--- a/lib/private/files/type/detection.php
+++ b/lib/private/files/type/detection.php
@@ -61,8 +61,6 @@ class Detection {
* @return string
*/
public function detect($path) {
- $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
-
if (@is_dir($path)) {
// directories are easy
return "httpd/unix-directory";
@@ -76,9 +74,11 @@ class Detection {
$info = @strtolower(finfo_file($finfo, $path));
if ($info) {
$mimeType = substr($info, 0, strpos($info, ';'));
+ return empty($mimeType) ? 'application/octet-stream' : $mimeType;
}
finfo_close($finfo);
}
+ $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
// use mime magic extension if available
$mimeType = mime_content_type($path);
@@ -94,6 +94,10 @@ class Detection {
//trim the newline
$mimeType = trim($reply);
+ if (empty($mimeType)) {
+ $mimeType = 'application/octet-stream';
+ }
+
}
return $mimeType;
}