From 3d19bb2e51333fed3edb106c52740a8dba4f700c Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 23 Oct 2014 14:57:53 +0200 Subject: [PATCH 1/3] also try to get file info from part file --- apps/files_encryption/lib/proxy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 31723ae764..55f2df783c 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -345,8 +345,8 @@ class Proxy extends \OC_FileProxy { return $size; } - // get file info from database/cache if not .part file - if (empty($fileInfo) && !Helper::isPartialFilePath($path)) { + // get file info from database/cache + if (empty($fileInfo)) { $proxyState = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; $fileInfo = $view->getFileInfo($path); From f27b6b0ab87b041229d564bbbabcd86a98dc6325 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 30 Oct 2014 10:51:25 +0100 Subject: [PATCH 2/3] don't scan part files --- lib/private/files/cache/cache.php | 8 ++++---- lib/private/files/view.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 7ea00325a1..2c12f83451 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -71,7 +71,7 @@ class Cache { if (empty(self::$mimetypeIds)) { $this->loadMimetypes(); } - + if (!isset(self::$mimetypeIds[$mime])) { try{ $result = \OC_DB::executeAudited('INSERT INTO `*PREFIX*mimetypes`(`mimetype`) VALUES(?)', array($mime)); @@ -82,8 +82,8 @@ class Cache { \OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG); return -1; } - } - + } + return self::$mimetypeIds[$mime]; } @@ -371,7 +371,7 @@ class Cache { $this->remove($child['path']); } } - + $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; \OC_DB::executeAudited($sql, array($entry['fileid'])); } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index e15a3063e9..0e4da30f7b 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -902,7 +902,7 @@ class View { $scanner = $storage->getScanner($internalPath); $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW); $data = $cache->get($internalPath); - } else if ($watcher->checkUpdate($internalPath, $data)) { + } else if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->checkUpdate($internalPath, $data)) { $this->updater->propagate($path); $data = $cache->get($internalPath); } From 2af7256267c8b16efcf68fec45c612d8c64c0c1d Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 27 Oct 2014 12:51:52 +0100 Subject: [PATCH 3/3] only set the values we need and make sure that we write the file info for both the real file and the part file, because some information from the part file might be needed later --- apps/files_encryption/lib/stream.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index 046c38152b..931aa08cb2 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -637,13 +637,17 @@ class Stream { $path = Helper::stripPartialFileExtension($this->rawPath); $fileInfo = array( + 'mimetype' => $this->rootView->getMimeType($this->rawPath), 'encrypted' => true, - 'size' => $this->size, 'unencrypted_size' => $this->unencryptedSize, ); - // set fileinfo - $this->rootView->putFileInfo($path, $fileInfo); + // if we write a part file we also store the unencrypted size for + // the part file so that it can be re-used later + $this->rootView->putFileInfo($this->rawPath, $fileInfo); + if ($path !== $this->rawPath) { + $this->rootView->putFileInfo($path, $fileInfo); + } }