summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_versions/lib/Storage.php16
-rw-r--r--settings/Controller/LogSettingsController.php3
-rw-r--r--tests/Settings/Controller/LogSettingsControllerTest.php6
3 files changed, 18 insertions, 7 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 93f8b848ce8..b14210af7b1 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -77,7 +77,7 @@ class Storage {
//until the end one version per week
6 => array('intervalEndsAfter' => -1, 'step' => 604800),
);
-
+
/** @var \OCA\Files_Versions\AppInfo\Application */
private static $application;
@@ -324,6 +324,13 @@ class Storage {
$files_view = new View('/'. User::getUser().'/files');
$versionCreated = false;
+ $fileInfo = $files_view->getFileInfo($file);
+
+ // check if user has the permissions to revert a version
+ if (!$fileInfo->isUpdateable()) {
+ return false;
+ }
+
//first create a new version
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
if (!$users_view->file_exists($version)) {
@@ -337,10 +344,9 @@ class Storage {
// This has to happen manually here since the file is manually copied below
$oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
$oldFileInfo = $users_view->getFileInfo($fileToRestore);
- $newFileInfo = $files_view->getFileInfo($filename);
- $cache = $newFileInfo->getStorage()->getCache();
+ $cache = $fileInfo->getStorage()->getCache();
$cache->update(
- $newFileInfo->getId(), [
+ $fileInfo->getId(), [
'encrypted' => $oldVersion,
'encryptedVersion' => $oldVersion,
'size' => $oldFileInfo->getSize()
@@ -680,7 +686,7 @@ class Storage {
public static function expire($filename) {
$config = \OC::$server->getConfig();
$expiration = self::getExpiration();
-
+
if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) {
if (!Filesystem::file_exists($filename)) {
diff --git a/settings/Controller/LogSettingsController.php b/settings/Controller/LogSettingsController.php
index 4863c2369be..6c9fe76c247 100644
--- a/settings/Controller/LogSettingsController.php
+++ b/settings/Controller/LogSettingsController.php
@@ -105,7 +105,8 @@ class LogSettingsController extends Controller {
*/
public function download() {
$resp = new StreamResponse(\OC\Log\Owncloud::getLogFilePath());
- $resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"');
+ $resp->addHeader('Content-Type', 'application/octet-stream');
+ $resp->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
return $resp;
}
}
diff --git a/tests/Settings/Controller/LogSettingsControllerTest.php b/tests/Settings/Controller/LogSettingsControllerTest.php
index 092c04aecc7..e3cfa072d08 100644
--- a/tests/Settings/Controller/LogSettingsControllerTest.php
+++ b/tests/Settings/Controller/LogSettingsControllerTest.php
@@ -12,6 +12,7 @@ namespace Tests\Settings\Controller;
use \OC\Settings\Application;
use OC\Settings\Controller\LogSettingsController;
+use OCP\AppFramework\Http\StreamResponse;
/**
* @package Tests\Settings\Controller
@@ -70,6 +71,9 @@ class LogSettingsControllerTest extends \Test\TestCase {
public function testDownload() {
$response = $this->logSettingsController->download();
- $this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response);
+ $expected = new StreamResponse(\OC\Log\Owncloud::getLogFilePath());
+ $expected->addHeader('Content-Type', 'application/octet-stream');
+ $expected->addHeader('Content-Disposition', 'attachment; filename="nextcloud.log"');
+ $this->assertEquals($expected, $response);
}
}