diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-10-16 18:28:45 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-10-26 15:41:23 +0100 |
commit | b900782513a750e5e100c7d55278632754a8df19 (patch) | |
tree | 2924f23ebc0325d8e83528079a768855e64584ff /tests | |
parent | cbd31e4fa9e7d4e469f2f3fc955e9b8e76f8628e (diff) | |
download | nextcloud-server-b900782513a750e5e100c7d55278632754a8df19.tar.gz nextcloud-server-b900782513a750e5e100c7d55278632754a8df19.zip |
Also adjust storage_mtime of target after rename
Some storages like Dropbox change their mtime on rename...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/updater.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index e3fa26829b4..b7e76aeace4 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -161,6 +161,47 @@ class Updater extends \Test\TestCase { $this->assertEquals($cached['fileid'], $cachedTarget['fileid']); } + public function testUpdateStorageMTime() { + $this->storage->mkdir('sub'); + $this->storage->mkdir('sub2'); + $this->storage->file_put_contents('sub/foo.txt', 'qwerty'); + + $this->updater->update('sub'); + $this->updater->update('sub/foo.txt'); + $this->updater->update('sub2'); + + $cachedSourceParent = $this->cache->get('sub'); + $cachedSource = $this->cache->get('sub/foo.txt'); + + $this->storage->rename('sub/foo.txt', 'sub2/bar.txt'); + + // simulate storage having a different mtime + $testmtime = 1433323578; + + // source storage mtime change + $this->storage->touch('sub', $testmtime); + + // target storage mtime change + $this->storage->touch('sub2', $testmtime); + // some storages (like Dropbox) change storage mtime on rename + $this->storage->touch('sub2/bar.txt', $testmtime); + + $this->updater->rename('sub/foo.txt', 'sub2/bar.txt'); + + $cachedTargetParent = $this->cache->get('sub2'); + $cachedTarget = $this->cache->get('sub2/bar.txt'); + + $this->assertEquals($cachedSource['mtime'], $cachedTarget['mtime'], 'file mtime preserved'); + + $this->assertNotEquals($cachedTarget['storage_mtime'], $cachedTarget['mtime'], 'mtime is not storage_mtime for moved file'); + + $this->assertEquals($testmtime, $cachedTarget['storage_mtime'], 'target file storage_mtime propagated'); + $this->assertNotEquals($testmtime, $cachedTarget['mtime'], 'target file mtime changed, not from storage'); + + $this->assertEquals($testmtime, $cachedTargetParent['storage_mtime'], 'target parent storage_mtime propagated'); + $this->assertNotEquals($testmtime, $cachedTargetParent['mtime'], 'target folder mtime changed, not from storage'); + } + public function testNewFileDisabled() { $this->storage->file_put_contents('foo.txt', 'bar'); $this->assertFalse($this->cache->inCache('foo.txt')); |