]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into move-storages
authorMichael Gapczynski <mtgap@owncloud.com>
Thu, 23 May 2013 14:25:12 +0000 (10:25 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Thu, 23 May 2013 14:25:12 +0000 (10:25 -0400)
Conflicts:
tests/lib/files/view.php

1  2 
lib/files/cache/scanner.php
lib/files/view.php
tests/lib/files/view.php

Simple merge
Simple merge
index a51d99e793d822e22b10376691b4bfef11a9b91d,af97761bbb7aa849823b9a4a95f2327e83543e48..01f9a9cca11966aeab52320319a31112131c8d9a
@@@ -228,43 -234,27 +234,64 @@@ class View extends \PHPUnit_Framework_T
                $this->assertEquals(3, $cachedData['size']);
        }
  
 +      function testCopyBetweenStorages() {
 +              $storage1 = $this->getTestStorage();
 +              $storage2 = $this->getTestStorage();
 +              \OC\Files\Filesystem::mount($storage1, array(), '/');
 +              \OC\Files\Filesystem::mount($storage2, array(), '/substorage');
 +
 +              $rootView = new \OC\Files\View('');
 +              $rootView->mkdir('substorage/emptyfolder');
 +              $rootView->copy('substorage', 'anotherfolder');
 +              $this->assertTrue($rootView->is_dir('/anotherfolder'));
 +              $this->assertTrue($rootView->is_dir('/substorage'));
 +              $this->assertTrue($rootView->is_dir('/anotherfolder/emptyfolder'));
 +              $this->assertTrue($rootView->is_dir('/substorage/emptyfolder'));
 +              $this->assertTrue($rootView->file_exists('/anotherfolder/foo.txt'));
 +              $this->assertTrue($rootView->file_exists('/anotherfolder/foo.png'));
 +              $this->assertTrue($rootView->file_exists('/anotherfolder/folder/bar.txt'));
 +              $this->assertTrue($rootView->file_exists('/substorage/foo.txt'));
 +              $this->assertTrue($rootView->file_exists('/substorage/foo.png'));
 +              $this->assertTrue($rootView->file_exists('/substorage/folder/bar.txt'));
 +      }
 +
 +      function testMoveBetweenStorages() {
 +              $storage1 = $this->getTestStorage();
 +              $storage2 = $this->getTestStorage();
 +              \OC\Files\Filesystem::mount($storage1, array(), '/');
 +              \OC\Files\Filesystem::mount($storage2, array(), '/substorage');
 +
 +              $rootView = new \OC\Files\View('');
 +              $rootView->rename('foo.txt', 'substorage/folder/foo.txt');
 +              $this->assertFalse($rootView->file_exists('foo.txt'));
 +              $this->assertTrue($rootView->file_exists('substorage/folder/foo.txt'));
 +              $rootView->rename('substorage/folder', 'anotherfolder');
 +              $this->assertFalse($rootView->is_dir('substorage/folder'));
 +              $this->assertTrue($rootView->file_exists('anotherfolder/foo.txt'));
 +              $this->assertTrue($rootView->file_exists('anotherfolder/bar.txt'));
 +      }
 +
+       function testTouch() {
+               $storage = $this->getTestStorage(true, '\Test\Files\TemporaryNoTouch');
+               \OC\Files\Filesystem::mount($storage, array(), '/');
+               $rootView = new \OC\Files\View('');
+               $oldCachedData = $rootView->getFileInfo('foo.txt');
+               $rootView->touch('foo.txt', 500);
+               $cachedData = $rootView->getFileInfo('foo.txt');
+               $this->assertEquals(500, $cachedData['mtime']);
+               $this->assertEquals($oldCachedData['storage_mtime'], $cachedData['storage_mtime']);
+               $rootView->putFileInfo('foo.txt', array('storage_mtime' => 1000)); //make sure the watcher detects the change
+               $rootView->file_put_contents('foo.txt', 'asd');
+               $cachedData = $rootView->getFileInfo('foo.txt');
+               $this->assertGreaterThanOrEqual($cachedData['mtime'], $oldCachedData['mtime']);
+               $this->assertEquals($cachedData['storage_mtime'], $cachedData['mtime']);
+       }
        /**
         * @param bool $scan
         * @return \OC\Files\Storage\Storage