diff options
-rw-r--r-- | apps/files_encryption/lib/migration.php | 28 | ||||
-rw-r--r-- | apps/files_external/tests/README.md | 5 | ||||
-rwxr-xr-x | autotest-external.sh | 9 | ||||
-rw-r--r-- | config/config.sample.php | 39 | ||||
-rw-r--r-- | console.php | 1 | ||||
-rw-r--r-- | lib/private/files/cache/updater.php | 19 | ||||
-rw-r--r-- | lib/private/files/view.php | 7 | ||||
-rw-r--r-- | tests/lib/files/cache/updater.php | 30 |
8 files changed, 103 insertions, 35 deletions
diff --git a/apps/files_encryption/lib/migration.php b/apps/files_encryption/lib/migration.php index 7a036ade3fc..ad954db7ebb 100644 --- a/apps/files_encryption/lib/migration.php +++ b/apps/files_encryption/lib/migration.php @@ -1,5 +1,5 @@ <?php - /** +/** * ownCloud * * @copyright (C) 2014 ownCloud, Inc. @@ -35,6 +35,7 @@ class Migration { public function __construct() { $this->view = new \OC\Files\View(); + $this->view->getUpdater()->disable(); $this->public_share_key_id = Helper::getPublicShareKeyId(); $this->recovery_key_id = Helper::getRecoveryKeyId(); } @@ -50,7 +51,7 @@ class Migration { $this->reorganizeFolderStructureForUser($user); } $offset += $limit; - } while(count($users) >= $limit); + } while (count($users) >= $limit); } public function reorganizeSystemFolderStructure() { @@ -74,6 +75,10 @@ class Migration { $this->view->deleteAll('/owncloud_private_key'); $this->view->deleteAll('/files_encryption/share-keys'); $this->view->deleteAll('/files_encryption/keyfiles'); + $storage = $this->view->getMount('')->getStorage(); + $storage->getScanner()->scan('files_encryption'); + $storage->getCache()->remove('owncloud_private_key'); + $storage->getCache()->remove('public-keys'); } @@ -96,6 +101,7 @@ class Migration { } // delete old folders $this->deleteOldKeys($user); + $this->view->getMount('/' . $user)->getStorage()->getScanner()->scan('files_encryption'); } } @@ -127,7 +133,7 @@ class Migration { while (($oldPublicKey = readdir($dh)) !== false) { if (!\OC\Files\Filesystem::isIgnoredDir($oldPublicKey)) { $newPublicKey = substr($oldPublicKey, 0, strlen($oldPublicKey) - strlen('.public.key')) . '.publicKey'; - $this->view->rename('public-keys/' . $oldPublicKey , 'files_encryption/public_keys/' . $newPublicKey); + $this->view->rename('public-keys/' . $oldPublicKey, 'files_encryption/public_keys/' . $newPublicKey); } } closedir($dh); @@ -141,7 +147,7 @@ class Migration { while (($oldPrivateKey = readdir($dh)) !== false) { if (!\OC\Files\Filesystem::isIgnoredDir($oldPrivateKey)) { $newPrivateKey = substr($oldPrivateKey, 0, strlen($oldPrivateKey) - strlen('.private.key')) . '.privateKey'; - $this->view->rename('owncloud_private_key/' . $oldPrivateKey , 'files_encryption/' . $newPrivateKey); + $this->view->rename('owncloud_private_key/' . $oldPrivateKey, 'files_encryption/' . $newPrivateKey); } } closedir($dh); @@ -149,10 +155,10 @@ class Migration { } private function renameUsersPrivateKey($user) { - $oldPrivateKey = $user . '/files_encryption/' . $user . '.private.key'; - $newPrivateKey = substr($oldPrivateKey, 0, strlen($oldPrivateKey) - strlen('.private.key')) . '.privateKey'; + $oldPrivateKey = $user . '/files_encryption/' . $user . '.private.key'; + $newPrivateKey = substr($oldPrivateKey, 0, strlen($oldPrivateKey) - strlen('.private.key')) . '.privateKey'; - $this->view->rename($oldPrivateKey, $newPrivateKey); + $this->view->rename($oldPrivateKey, $newPrivateKey); } private function getFileName($file, $trash) { @@ -186,7 +192,7 @@ class Migration { } private function getFilePath($path, $user, $trash) { - $offset = $trash ? strlen($user . '/files_trashbin/keyfiles') : strlen($user . '/files_encryption/keyfiles'); + $offset = $trash ? strlen($user . '/files_trashbin/keyfiles') : strlen($user . '/files_encryption/keyfiles'); return substr($path, $offset); } @@ -215,7 +221,7 @@ class Migration { $extension = $this->getExtension($file, $trash); $targetDir = $this->getTargetDir($user, $filePath, $filename, $extension, $trash); $this->createPathForKeys($targetDir); - $this->view->copy($path . '/' . $file, $targetDir . '/fileKey'); + $this->view->rename($path . '/' . $file, $targetDir . '/fileKey'); $this->renameShareKeys($user, $filePath, $filename, $targetDir, $trash); } } @@ -258,10 +264,10 @@ class Migration { if ($this->view->is_dir($oldShareKeyPath . '/' . $file)) { continue; } else { - if (substr($file, 0, strlen($filename) +1) === $filename . '.') { + if (substr($file, 0, strlen($filename) + 1) === $filename . '.') { $uid = $this->getUidFromShareKey($file, $filename, $trash); - $this->view->copy($oldShareKeyPath . '/' . $file, $target . '/' . $uid . '.shareKey'); + $this->view->rename($oldShareKeyPath . '/' . $file, $target . '/' . $uid . '.shareKey'); } } diff --git a/apps/files_external/tests/README.md b/apps/files_external/tests/README.md index 35a0232434e..0b3c7fd004f 100644 --- a/apps/files_external/tests/README.md +++ b/apps/files_external/tests/README.md @@ -42,6 +42,11 @@ then runs the unit test suite from `backends/webdav.php` (because the middle par the name of the script is `webdav`) and finally tries to call `stop-webdav-ownCloud.sh` for cleanup purposes. +If `common-tests` is supplied as second argument it will skip the backend specific +part completely and just run the common files_external unit tests: + + ./autotest-external.sh sqlite common-tests + ## The more manual way of unit test execution If you want to debug your external storage provider, you maybe don't want to diff --git a/autotest-external.sh b/autotest-external.sh index 74acddfd7a0..8254defc9ca 100755 --- a/autotest-external.sh +++ b/autotest-external.sh @@ -24,6 +24,7 @@ function print_syntax { echo -e "\nExample: ./autotest.sh sqlite webdav-ownCloud" >&2 echo "will run the external suite from \"apps/files_external/tests/env/start-webdav-ownCloud.sh\"" >&2 echo -e "\nIf no arguments are specified, all available external backends will be run with all database configs" >&2 + echo -e "\nIf you specify 'common-tests' as startfile it will just run the tests that are independent from the backends" >&2 } if ! [ -x "$PHPUNIT" ]; then @@ -219,14 +220,18 @@ EOF # just enable files_external php ../occ app:enable files_external if [ -z "$NOCOVERAGE" ]; then - #"$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml" --coverage-clover "autotest-external-clover-$1.xml" --coverage-html "coverage-external-html-$1" + "$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml" --coverage-clover "autotest-external-clover-$1.xml" --coverage-html "coverage-external-html-$1" RESULT=$? else echo "No coverage" - #"$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml" + "$PHPUNIT" --configuration phpunit-autotest-external.xml --log-junit "autotest-external-results-$1.xml" RESULT=$? fi + if [ -n "$2" -a "$2" == "common-tests" ]; then + return; + fi + FILES_EXTERNAL_BACKEND_PATH=../apps/files_external/tests/backends FILES_EXTERNAL_BACKEND_ENV_PATH=../apps/files_external/tests/env diff --git a/config/config.sample.php b/config/config.sample.php index 10b079caa8a..1b3477417ff 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -48,15 +48,15 @@ $CONFIG = array( 'instanceid' => '', /** - * The salt used to hash all passwords, auto-generated by the ownCloud - * installer. (There are also per-user salts.) If you lose this salt you lose - * all your passwords. This example is for documentation only, - * and you should never use it. - * - * @deprecated This salt is deprecated and only used for legacy-compatibility, developers - * should *NOT* use this value for anything nowadays. - * - *'passwordsalt' => 'd3c944a9af095aa08f', + * The salt used to hash all passwords, auto-generated by the ownCloud + * installer. (There are also per-user salts.) If you lose this salt you lose + * all your passwords. This example is for documentation only, and you should + * never use it. + * + * @deprecated This salt is deprecated and only used for legacy-compatibility, + * developers should *NOT* use this value for anything nowadays. + * + * 'passwordsalt' => 'd3c944a9af095aa08f', */ 'passwordsalt' => '', @@ -80,8 +80,8 @@ $CONFIG = array( /** * Where user files are stored; this defaults to ``data/`` in the ownCloud - * directory. The SQLite database is also stored here, when you use SQLite. (SQLite is - * available only in ownCloud Community Edition) + * directory. The SQLite database is also stored here, when you use SQLite. + * (SQLite is available only in ownCloud Community Edition) */ 'datadirectory' => '/var/www/owncloud/data', @@ -145,8 +145,8 @@ $CONFIG = array( ), /** - * sqlite3 journal mode can be specified using this config parameter - can be 'WAL' or 'DELETE' - * see for more details https://www.sqlite.org/wal.html + * sqlite3 journal mode can be specified using this config parameter - can be + * 'WAL' or 'DELETE' see for more details https://www.sqlite.org/wal.html */ 'sqlite.journal_mode' => 'DELETE', @@ -512,8 +512,9 @@ $CONFIG = array( * Default is within the tmp directory. The file is named in the following way * owncloud-server-$INSTANCEID-cron.lock * where $INSTANCEID is the string specified in the instanceid field. - * Because the cron lock file is accessed in regular intervals, it may prevent enabled disk drives from spinning down. - * A different location for this file can solve such issues. + * Because the cron lock file is accessed in regular intervals, it may prevent + * enabled disk drives from spinning down. A different location for this file + * can solve such issues. */ 'cron.lockfile.location' => '', @@ -681,8 +682,8 @@ $CONFIG = array( * - OC\Preview\TIFF * * .. note:: Troubleshooting steps for the MS Word previews are available - * at the :doc:`collaborative_documents_configuration` section - * of the Administrators Manual. + * at the :doc:`../configuration_files/collaborative_documents_configuration` + * section of the Administrators Manual. * * The following providers are not available in Microsoft Windows: * @@ -812,8 +813,8 @@ $CONFIG = array( /** * Server details for one or more memcached servers to use for memory caching. - * Memcache is only used if other memory cache options (xcache, apc, apcu, redis) are - * not available. + * Memcache is only used if other memory cache options (xcache, apc, apcu, + * redis) are not available. */ 'memcached_servers' => array( // hostname, port and optional weight. Also see: diff --git a/console.php b/console.php index af58aacd25a..9e6240d92cd 100644 --- a/console.php +++ b/console.php @@ -58,4 +58,5 @@ try { } catch (Exception $ex) { echo "An unhandled exception has been thrown:" . PHP_EOL; echo $ex; + exit(1); } diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index eeb763921bb..248748ea4a9 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -13,6 +13,11 @@ namespace OC\Files\Cache; */ class Updater { /** + * @var bool + */ + protected $enabled = true; + + /** * @var \OC\Files\View */ protected $view; @@ -30,6 +35,14 @@ class Updater { $this->propagator = new ChangePropagator($view); } + public function disable() { + $this->enabled = false; + } + + public function enable() { + $this->enabled = true; + } + public function propagate($path, $time = null) { if (Scanner::isPartialFile($path)) { return; @@ -45,7 +58,7 @@ class Updater { * @param int $time */ public function update($path, $time = null) { - if (Scanner::isPartialFile($path)) { + if (!$this->enabled or Scanner::isPartialFile($path)) { return; } /** @@ -70,7 +83,7 @@ class Updater { * @param string $path */ public function remove($path) { - if (Scanner::isPartialFile($path)) { + if (!$this->enabled or Scanner::isPartialFile($path)) { return; } /** @@ -97,7 +110,7 @@ class Updater { * @param string $target */ public function rename($source, $target) { - if (Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) { + if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) { return; } /** diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 9cf7eaa2ec1..4f9a4001d69 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1528,4 +1528,11 @@ class View { $mount ); } + + /** + * @return Updater + */ + public function getUpdater(){ + return $this->updater; + } } diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index 01b036de5d8..970af2e68df 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -146,4 +146,34 @@ class Updater extends \Test\TestCase { $this->assertEquals($cached['size'], $cachedTarget['size']); $this->assertEquals($cached['fileid'], $cachedTarget['fileid']); } + + public function testNewFileDisabled() { + $this->storage->file_put_contents('foo.txt', 'bar'); + $this->assertFalse($this->cache->inCache('foo.txt')); + + $this->updater->disable(); + $this->updater->update('/foo.txt'); + + $this->assertFalse($this->cache->inCache('foo.txt')); + } + + public function testMoveDisabled() { + $this->storage->file_put_contents('foo.txt', 'qwerty'); + $this->updater->update('foo.txt'); + + $this->assertTrue($this->cache->inCache('foo.txt')); + $this->assertFalse($this->cache->inCache('bar.txt')); + $cached = $this->cache->get('foo.txt'); + + $this->storage->rename('foo.txt', 'bar.txt'); + + $this->assertTrue($this->cache->inCache('foo.txt')); + $this->assertFalse($this->cache->inCache('bar.txt')); + + $this->updater->disable(); + $this->updater->rename('foo.txt', 'bar.txt'); + + $this->assertTrue($this->cache->inCache('foo.txt')); + $this->assertFalse($this->cache->inCache('bar.txt')); + } } |