summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-08-06 09:30:28 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-08-06 09:30:28 +0200
commit6599dc1b5ca57a8460f9e26893e3254a554e03a9 (patch)
treedf823b0d5002466a097232daab8f5b7451cbea2b /apps
parente902e3f6591f53ebd199a4db8c791fce322788ce (diff)
parent785ae5dc9adc4030ab9144b62b62dd40fe4ffc75 (diff)
downloadnextcloud-server-6599dc1b5ca57a8460f9e26893e3254a554e03a9.tar.gz
nextcloud-server-6599dc1b5ca57a8460f9e26893e3254a554e03a9.zip
Merge pull request #10186 from owncloud/versioning_fix_path
[versioning] make sure that getVersions() return the correct path
Diffstat (limited to 'apps')
-rw-r--r--apps/files_versions/lib/versions.php4
-rw-r--r--apps/files_versions/tests/versions.php34
2 files changed, 36 insertions, 2 deletions
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index a9d51b2c58b..7fadf81426b 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -265,7 +265,7 @@ class Storage {
$pathinfo = pathinfo($filename);
$versionedFile = $pathinfo['basename'];
- $dir = self::VERSIONS_ROOT . '/' . $pathinfo['dirname'];
+ $dir = \OC\Files\Filesystem::normalizePath(self::VERSIONS_ROOT . '/' . $pathinfo['dirname']);
$dirContent = false;
if ($view->is_dir($dir)) {
@@ -293,7 +293,7 @@ class Storage {
} else {
$versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $userFullPath, 'version' => $timestamp));
}
- $versions[$key]['path'] = $filename;
+ $versions[$key]['path'] = $pathinfo['dirname'] . '/' . $filename;
$versions[$key]['name'] = $versionedFile;
$versions[$key]['size'] = $view->filesize($dir . '/' . $entryName);
}
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 03432276358..558c8dfcb8a 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -267,6 +267,40 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
}
/**
+ * test if we find all versions and if the versions array contain
+ * the correct 'path' and 'name'
+ */
+ public function testGetVersions() {
+
+ $t1 = time();
+ // second version is two weeks older, this way we make sure that no
+ // version will be expired
+ $t2 = $t1 - 60 * 60 * 24 * 14;
+
+ // create some versions
+ $v1 = self::USERS_VERSIONS_ROOT . '/subfolder/test.txt.v' . $t1;
+ $v2 = self::USERS_VERSIONS_ROOT . '/subfolder/test.txt.v' . $t2;
+
+ $this->rootView->mkdir(self::USERS_VERSIONS_ROOT . '/subfolder/');
+
+ $this->rootView->file_put_contents($v1, 'version1');
+ $this->rootView->file_put_contents($v2, 'version2');
+
+ // execute copy hook of versions app
+ $versions = \OCA\Files_Versions\Storage::getVersions(self::TEST_VERSIONS_USER, '/subfolder/test.txt');
+
+ $this->assertSame(2, count($versions));
+
+ foreach ($versions as $version) {
+ $this->assertSame('/subfolder/test.txt', $version['path']);
+ $this->assertSame('test.txt', $version['name']);
+ }
+
+ //cleanup
+ $this->rootView->deleteAll(self::USERS_VERSIONS_ROOT . '/subfolder');
+ }
+
+ /**
* @param string $user
* @param bool $create
* @param bool $password