aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/ajax/preview.php1
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php1
-rw-r--r--apps/files_versions/appinfo/app.php1
-rw-r--r--apps/files_versions/appinfo/routes.php1
-rw-r--r--apps/files_versions/appinfo/update.php1
-rw-r--r--apps/files_versions/command/expire.php30
-rw-r--r--apps/files_versions/download.php3
-rw-r--r--apps/files_versions/l10n/oc.js11
-rw-r--r--apps/files_versions/l10n/oc.json9
-rw-r--r--apps/files_versions/l10n/th_TH.js4
-rw-r--r--apps/files_versions/l10n/th_TH.json4
-rw-r--r--apps/files_versions/lib/storage.php7
-rw-r--r--apps/files_versions/tests/command/expiretest.php34
-rw-r--r--apps/files_versions/tests/versions.php13
14 files changed, 109 insertions, 11 deletions
diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php
index 2d3a8477f17..8a9a5fba14c 100644
--- a/apps/files_versions/ajax/preview.php
+++ b/apps/files_versions/ajax/preview.php
@@ -1,7 +1,6 @@
<?php
/**
* @author Björn Schießle <schiessle@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php
index 3f4d78af82b..e75df28dbcd 100644
--- a/apps/files_versions/ajax/rollbackVersion.php
+++ b/apps/files_versions/ajax/rollbackVersion.php
@@ -4,7 +4,6 @@
* @author Björn Schießle <schiessle@owncloud.com>
* @author Frank Karlitschek <frank@owncloud.org>
* @author Lukas Reschke <lukas@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
* @author Sam Tuke <mail@samtuke.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php
index 0705371b8f4..3bad0d8a94d 100644
--- a/apps/files_versions/appinfo/app.php
+++ b/apps/files_versions/appinfo/app.php
@@ -2,7 +2,6 @@
/**
* @author Björn Schießle <schiessle@owncloud.com>
* @author Frank Karlitschek <frank@owncloud.org>
- * @author Morris Jobke <hey@morrisjobke.de>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php
index 0ea37d3b1b1..5dbed1f93eb 100644
--- a/apps/files_versions/appinfo/routes.php
+++ b/apps/files_versions/appinfo/routes.php
@@ -1,6 +1,7 @@
<?php
/**
* @author Björn Schießle <schiessle@owncloud.com>
+ * @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
diff --git a/apps/files_versions/appinfo/update.php b/apps/files_versions/appinfo/update.php
index 6fa0fd6185f..524f9bd153f 100644
--- a/apps/files_versions/appinfo/update.php
+++ b/apps/files_versions/appinfo/update.php
@@ -1,7 +1,6 @@
<?php
/**
* @author Björn Schießle <schiessle@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
diff --git a/apps/files_versions/command/expire.php b/apps/files_versions/command/expire.php
index d6523746525..4492497f851 100644
--- a/apps/files_versions/command/expire.php
+++ b/apps/files_versions/command/expire.php
@@ -1,9 +1,24 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
*/
namespace OCA\Files_Versions\Command;
@@ -11,7 +26,6 @@ namespace OCA\Files_Versions\Command;
use OC\Command\FileAccess;
use OCA\Files_Versions\Storage;
use OCP\Command\ICommand;
-use OCP\IUser;
class Expire implements ICommand {
use FileAccess;
@@ -51,6 +65,12 @@ class Expire implements ICommand {
public function handle() {
+ $userManager = \OC::$server->getUserManager();
+ if (!$userManager->userExists($this->user)) {
+ // User has been deleted already
+ return;
+ }
+
\OC_Util::setupFS($this->user);
Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
\OC_Util::tearDownFS();
diff --git a/apps/files_versions/download.php b/apps/files_versions/download.php
index 72018ca68b9..22a218f472a 100644
--- a/apps/files_versions/download.php
+++ b/apps/files_versions/download.php
@@ -1,5 +1,6 @@
<?php
/**
+ * @author Andreas Fischer <bantu@owncloud.com>
* @author Björn Schießle <schiessle@owncloud.com>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -34,7 +35,7 @@ $versionName = '/'.$uid.'/files_versions/'.$filename.'.v'.$revision;
$view = new OC\Files\View('/');
-$ftype = $view->getMimeType('/'.$uid.'/files/'.$filename);
+$ftype = \OC_Helper::getSecureMimeType($view->getMimeType('/'.$uid.'/files/'.$filename));
header('Content-Type:'.$ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
diff --git a/apps/files_versions/l10n/oc.js b/apps/files_versions/l10n/oc.js
new file mode 100644
index 00000000000..dbb8fa894cb
--- /dev/null
+++ b/apps/files_versions/l10n/oc.js
@@ -0,0 +1,11 @@
+OC.L10N.register(
+ "files_versions",
+ {
+ "Could not revert: %s" : "Impossible de restablir %s",
+ "Versions" : "Versions",
+ "Failed to revert {file} to revision {timestamp}." : "Fracàs del retorn del fichièr {file} a la revision {timestamp}.",
+ "More versions..." : "Mai de versions...",
+ "No other versions available" : "Cap d'autra version es pas disponibla",
+ "Restore" : "Restablir"
+},
+"nplurals=2; plural=(n > 1);");
diff --git a/apps/files_versions/l10n/oc.json b/apps/files_versions/l10n/oc.json
new file mode 100644
index 00000000000..cf3ddd95d33
--- /dev/null
+++ b/apps/files_versions/l10n/oc.json
@@ -0,0 +1,9 @@
+{ "translations": {
+ "Could not revert: %s" : "Impossible de restablir %s",
+ "Versions" : "Versions",
+ "Failed to revert {file} to revision {timestamp}." : "Fracàs del retorn del fichièr {file} a la revision {timestamp}.",
+ "More versions..." : "Mai de versions...",
+ "No other versions available" : "Cap d'autra version es pas disponibla",
+ "Restore" : "Restablir"
+},"pluralForm" :"nplurals=2; plural=(n > 1);"
+} \ No newline at end of file
diff --git a/apps/files_versions/l10n/th_TH.js b/apps/files_versions/l10n/th_TH.js
index 72a456dc0ce..81559c9cea3 100644
--- a/apps/files_versions/l10n/th_TH.js
+++ b/apps/files_versions/l10n/th_TH.js
@@ -1,7 +1,11 @@
OC.L10N.register(
"files_versions",
{
+ "Could not revert: %s" : "ไม่สามารถย้อนกลับ: %s",
"Versions" : "รุ่น",
+ "Failed to revert {file} to revision {timestamp}." : "{file} ล้มเหลวที่จะย้อนกลับ มีการแก้ไขเมื่อ {timestamp}",
+ "More versions..." : "รุ่นอื่นๆ ...",
+ "No other versions available" : "ไม่มีรุ่นอื่นๆ",
"Restore" : "คืนค่า"
},
"nplurals=1; plural=0;");
diff --git a/apps/files_versions/l10n/th_TH.json b/apps/files_versions/l10n/th_TH.json
index 1d87f34b101..bd07d72a582 100644
--- a/apps/files_versions/l10n/th_TH.json
+++ b/apps/files_versions/l10n/th_TH.json
@@ -1,5 +1,9 @@
{ "translations": {
+ "Could not revert: %s" : "ไม่สามารถย้อนกลับ: %s",
"Versions" : "รุ่น",
+ "Failed to revert {file} to revision {timestamp}." : "{file} ล้มเหลวที่จะย้อนกลับ มีการแก้ไขเมื่อ {timestamp}",
+ "More versions..." : "รุ่นอื่นๆ ...",
+ "No other versions available" : "ไม่มีรุ่นอื่นๆ",
"Restore" : "คืนค่า"
},"pluralForm" :"nplurals=1; plural=0;"
} \ No newline at end of file
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 98e486690b6..e0034f6165f 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -5,6 +5,7 @@
* @author Felix Moeller <mail@felixmoeller.de>
* @author Florin Peter <github@florin-peter.de>
* @author Georg Ehrke <georg@owncloud.com>
+ * @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
@@ -346,7 +347,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 +557,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/command/expiretest.php b/apps/files_versions/tests/command/expiretest.php
new file mode 100644
index 00000000000..247fb99b767
--- /dev/null
+++ b/apps/files_versions/tests/command/expiretest.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Versions\Tests\Command;
+
+use OCA\Files_Versions\Command\Expire;
+use Test\TestCase;
+
+class ExpireTest extends TestCase {
+ public function testExpireNonExistingUser() {
+ $command = new Expire('test', '');
+ $command->handle();
+
+ $this->assertTrue(true);
+ }
+}
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 97afcf715cb..7cca409ed6c 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -4,7 +4,9 @@
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Vincent Petry <pvince81@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
@@ -552,10 +554,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();
@@ -753,6 +765,7 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId($user);
\OC_Util::setupFS($user);
+ \OC::$server->getUserFolder($user);
}
}