aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-06-01 16:17:00 +0200
committerVincent Petry <pvince81@owncloud.com>2015-06-01 17:35:30 +0200
commit1fb44bc7a7a8cde197fa8a4fee7fe2f49e69562e (patch)
tree3ec0a2819f274e673348c75ee7564f4a4a1d9bf0
parent52d09386d49dd9fb7fd1764d17c8b504928f80d1 (diff)
downloadnextcloud-server-1fb44bc7a7a8cde197fa8a4fee7fe2f49e69562e.tar.gz
nextcloud-server-1fb44bc7a7a8cde197fa8a4fee7fe2f49e69562e.zip
Properly return fileid when scanFile() did not find differences
-rw-r--r--lib/private/files/cache/scanner.php2
-rw-r--r--tests/lib/files/cache/scanner.php8
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 4778a6803ba..166c4e89b0a 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -155,6 +155,8 @@ class Scanner extends BasicEmitter {
$data['fileid'] = $this->addToCache($file, $newData);
$this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId));
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
+ } else if (!empty($cacheData)) {
+ $data['fileid'] = $cacheData['fileid'];
}
} else {
$this->removeFromCache($file);
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index b44cf0a49df..c17413678ac 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -181,6 +181,14 @@ class Scanner extends \Test\TestCase {
$this->assertEquals($oldData['size'], $newData['size']);
}
+ public function testReuseIdentical() {
+ $this->storage->file_put_contents('file.txt', 'contents');
+ $data = $this->scanner->scanFile('file.txt', \OC\Files\Cache\Scanner::REUSE_ETAG);
+ $this->assertTrue(isset($data['fileid']));
+ $data = $this->scanner->scanFile('file.txt', \OC\Files\Cache\Scanner::REUSE_ETAG);
+ $this->assertTrue(isset($data['fileid']));
+ }
+
public function testRemovedFile() {
$this->fillTestFolders();