From 1397d9a93c0b86f412688825871cbbe8b841f9b5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Apr 2016 17:23:48 +0200 Subject: triger the propagator from the command line scanner --- lib/private/files/utils/scanner.php | 16 ++++++++++++++++ tests/lib/files/utils/scanner.php | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index 06526583899..b013cbecabc 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -29,6 +29,7 @@ use OC\Files\Filesystem; use OC\ForbiddenException; use OC\Hooks\PublicEmitter; use OC\Lock\DBLockingProvider; +use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\ILogger; @@ -153,6 +154,17 @@ class Scanner extends PublicEmitter { $scanner->setUseTransactions(false); $this->attachListener($mount); $isDbLocking = \OC::$server->getLockingProvider() instanceof DBLockingProvider; + + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { + $this->triggerPropagator($storage, $path); + }); + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { + $this->triggerPropagator($storage, $path); + }); + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { + $this->triggerPropagator($storage, $path); + }); + if (!$isDbLocking) { $this->db->beginTransaction(); } @@ -168,5 +180,9 @@ class Scanner extends PublicEmitter { } } } + + private function triggerPropagator(IStorage $storage, $internalPath) { + $storage->getPropagator()->propagateChange($internalPath, time()); + } } diff --git a/tests/lib/files/utils/scanner.php b/tests/lib/files/utils/scanner.php index 7779e2778cb..1220c57e962 100644 --- a/tests/lib/files/utils/scanner.php +++ b/tests/lib/files/utils/scanner.php @@ -163,4 +163,28 @@ class Scanner extends \Test\TestCase { $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger()); $scanner->scan($invalidPath); } + + public function testPropagateEtag() { + $storage = new Temporary(array()); + $mount = new MountPoint($storage, ''); + Filesystem::getMountManager()->addMount($mount); + $cache = $storage->getCache(); + + $storage->mkdir('folder'); + $storage->file_put_contents('folder/bar.txt', 'qwerty'); + $storage->touch('folder/bar.txt', time() - 200); + + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger()); + $scanner->addMount($mount); + + $scanner->scan(''); + $this->assertTrue($cache->inCache('folder/bar.txt')); + $oldRoot = $cache->get(''); + + $storage->file_put_contents('folder/bar.txt', 'qwerty'); + $scanner->scan(''); + $newRoot = $cache->get(''); + + $this->assertNotEquals($oldRoot->getEtag(), $newRoot->getEtag()); + } } -- cgit v1.2.3 From e542bfd1d7044e6eeec9d0cf4c815a1e85614458 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 25 Apr 2016 18:36:50 +0200 Subject: check whether index is set before using it --- lib/private/installer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/installer.php b/lib/private/installer.php index fca9fce23ef..f1d4d551786 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -269,7 +269,8 @@ class OC_Installer{ //download the file if necessary if($data['source']=='http') { $pathInfo = pathinfo($data['href']); - $path = \OC::$server->getTempManager()->getTemporaryFile('.' . $pathInfo['extension']); + $extension = isset($pathInfo['extension']) ? '.' . $pathInfo['extension'] : ''; + $path = \OC::$server->getTempManager()->getTemporaryFile($extension); if(!isset($data['href'])) { throw new \Exception($l->t("No href specified when installing app from http")); } -- cgit v1.2.3 From a70d6f6a62863711ed33707736bdf40b218b8f3b Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 22 Mar 2016 20:28:57 +0100 Subject: Disable pastezone for jquery.fileupload jquery.fileupload offers the [`pastezone`](https://github.com/blueimp/jQuery-File-Upload/wiki/Options#pastezone) functionality. This functionality is enabled by default and if somebody copy-pastes something into Chrome it will automatically trigger an upload of the content to any configured jquery.fileupload element embedded in the JS. This implementation triggers some problems: 1. The pastezone is defined globally by default (:see_no_evil:). So if there are multiple fileupload's on a page (such as in the personal settings) then stuff is going to be uploaded to all embedded uploads. 2. Our server code is not able to parse the data. For example for uploads in the files app we expect a file name which is not specified => Just an error is thrown. You can reproduce this by taking a file into your clipboard and in Chrome then pressing CTRL + V. 3. When copy-pasting some string from MS Office on the personal page a temporary avatar with said content is created. Considering that this is anyways was never working at all and causes bugs I've set the `pastezone` to `null`. This mens that upload via copy and paste will be disabled. Lesson learned: Third-party JS libraries can have some weird details. --- apps/files/js/file-upload.js | 1 + settings/js/certificates.js | 1 + settings/js/personal.js | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index bd80afd072c..fca69064cde 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -274,6 +274,7 @@ OC.Upload = { if ( $('#file_upload_start').exists() ) { var file_upload_param = { dropZone: $('#content'), // restrict dropZone to content div + pasteZone: null, autoUpload: false, sequentialUploads: true, //singleFileUploads is on by default, so the data.files array will always have length 1 diff --git a/settings/js/certificates.js b/settings/js/certificates.js index 9ce9f9aa8d8..f2a8e6b0afb 100644 --- a/settings/js/certificates.js +++ b/settings/js/certificates.js @@ -16,6 +16,7 @@ $(document).ready(function () { $('#sslCertificate tr > td').tipsy({gravity: 'n', live: true}); $('#rootcert_import').fileupload({ + pasteZone: null, submit: function (e, data) { data.formData = _.extend(data.formData || {}, { requesttoken: OC.requestToken diff --git a/settings/js/personal.js b/settings/js/personal.js index 3b2316d0614..bd13b7fd251 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -244,6 +244,7 @@ $(document).ready(function () { }); var uploadparms = { + pasteZone: null, done: function (e, data) { var response = data; if (typeof data.result === 'string') { -- cgit v1.2.3 From 590ed3eddaab33f7a05040c23b07a56c18c8dea6 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 26 Apr 2016 11:52:47 +0200 Subject: Also exclude __apps Workaround for https://github.com/owncloud/updater/issues/331 for 9.0.2 --- .../integritycheck/iterator/excludefoldersbypathfilteriterator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php index e4b9c0f1998..29deea6268d 100644 --- a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php +++ b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php @@ -44,6 +44,7 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 rtrim($root . '/updater', '/'), rtrim($root . '/_oc_upgrade', '/'), + rtrim($root . '/__apps', '/'), ]; $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); if($customDataDir !== '') { -- cgit v1.2.3 From 7ee7d091f2bb1d0271507782bf193b232f9199c3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 26 Apr 2016 13:18:18 +0200 Subject: Don't write empty RewriteBase ownCloud may be configured to live at the root folder without a trailing slash being specified. In this case manually set the rewrite base to `/` --- lib/private/setup.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/private/setup.php b/lib/private/setup.php index d2f3802ebad..196ae8a8bce 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -427,10 +427,18 @@ class Setup { //custom 404 error page $content.= "\nErrorDocument 404 ".$webRoot."/core/templates/404.php"; + // ownCloud may be configured to live at the root folder without a + // trailing slash being specified. In this case manually set the + // rewrite base to `/` + $rewriteBase = $webRoot; + if($webRoot === '') { + $rewriteBase = '/'; + } + // Add rewrite base $content .= "\n"; $content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]"; - $content .= "\n RewriteBase ".$webRoot; + $content .= "\n RewriteBase ".$rewriteBase; $content .= "\n "; $content .= "\n SetEnv front_controller_active true"; $content .= "\n "; -- cgit v1.2.3