[Pkg-owncloud-commits] [owncloud] 183/457: Abort expiration when file is gone

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:06:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 9a6d253af39dba49a1397416fb448e922df8a7a1
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri May 29 13:15:12 2015 +0200

    Abort expiration when file is gone
    
    Sometimes a background job for versions expiration was scheduled for a
    file that has been moved or deleted since.
    
    This prevents showing useless warnings in the log and simply bail out.
---
 apps/files_versions/lib/storage.php    |  6 +++++-
 apps/files_versions/tests/versions.php | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 98e4866..296cebf 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -346,7 +346,7 @@ class Storage {
 	 */
 	public static function getVersions($uid, $filename, $userFullPath = '') {
 		$versions = array();
-		if ($filename === '') {
+		if (empty($filename)) {
 			return $versions;
 		}
 		// fetch for old versions
@@ -556,6 +556,10 @@ class Storage {
 		$config = \OC::$server->getConfig();
 		if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
 			list($uid, $filename) = self::getUidAndFilename($filename);
+			if (empty($filename)) {
+				// file maybe renamed or deleted
+				return false;
+			}
 			$versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
 
 			// get available disk space for user
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 685bf48..0b6bfc6 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -552,10 +552,20 @@ class Test_Files_Versioning extends \Test\TestCase {
 	public function testGetVersionsEmptyFile() {
 		// execute copy hook of versions app
 		$versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '');
+		$this->assertCount(0, $versions);
 
+		$versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, null);
 		$this->assertCount(0, $versions);
 	}
 
+	public function testExpireNonexistingFile() {
+		$this->logout();
+		// needed to have a FS setup (the background job does this)
+		\OC_Util::setupFS(self::TEST_VERSIONS_USER);
+
+		$this->assertFalse(\OCA\Files_Versions\Storage::expire('/void/unexist.txt'));
+	}
+
 	public function testRestoreSameStorage() {
 		\OC\Files\Filesystem::mkdir('sub');
 		$this->doTestRestore();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list