summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-30 21:18:49 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-05-01 08:38:59 +0200
commit5401732cd2aa0a47aa14ee7618b65214d65849ee (patch)
tree40683d9125b1e590275ff888cbabf53fc366dd44 /apps
parentdd47ebb06299f683e5933cf6038f2ff1a0f813ea (diff)
downloadnextcloud-server-5401732cd2aa0a47aa14ee7618b65214d65849ee.tar.gz
nextcloud-server-5401732cd2aa0a47aa14ee7618b65214d65849ee.zip
Allow to read get old versions
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_versions/lib/Sabre/VersionCollection.php2
-rw-r--r--apps/files_versions/lib/Sabre/VersionFile.php22
2 files changed, 20 insertions, 4 deletions
diff --git a/apps/files_versions/lib/Sabre/VersionCollection.php b/apps/files_versions/lib/Sabre/VersionCollection.php
index 96a5e06bc25..481a5f491c3 100644
--- a/apps/files_versions/lib/Sabre/VersionCollection.php
+++ b/apps/files_versions/lib/Sabre/VersionCollection.php
@@ -71,7 +71,7 @@ class VersionCollection implements ICollection {
$versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath()));
return array_map(function (array $data) {
- return new VersionFile($data);
+ return new VersionFile($data, $this->userFolder->getParent());
}, $versions);
}
diff --git a/apps/files_versions/lib/Sabre/VersionFile.php b/apps/files_versions/lib/Sabre/VersionFile.php
index b84215cb3d6..347058448fc 100644
--- a/apps/files_versions/lib/Sabre/VersionFile.php
+++ b/apps/files_versions/lib/Sabre/VersionFile.php
@@ -24,16 +24,23 @@ declare(strict_types=1);
namespace OCA\Files_Versions\Sabre;
use OCA\Files_Versions\Storage;
-use OCP\Files\FileInfo;
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\NotFoundException;
use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\IFile;
class VersionFile implements IFile {
/** @var array */
private $data;
- public function __construct(array $data) {
+ /** @var Folder */
+ private $userRoot;
+
+ public function __construct(array $data, Folder $userRoot) {
$this->data = $data;
+ $this->userRoot = $userRoot;
}
public function put($data) {
@@ -41,7 +48,16 @@ class VersionFile implements IFile {
}
public function get() {
- throw new Forbidden();
+ try {
+ /** @var Folder $versions */
+ $versions = $this->userRoot->get('files_versions');
+ /** @var File $version */
+ $version = $versions->get($this->data['path'].'.v'.$this->data['version']);
+ } catch (NotFoundException $e) {
+ throw new NotFound();
+ }
+
+ return $version->fopen('rb');
}
public function getContentType(): string {