Allow to read get old versions
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
dd47ebb062
commit
5401732cd2
|
@ -71,7 +71,7 @@ class VersionCollection implements ICollection {
|
||||||
$versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath()));
|
$versions = Storage::getVersions($this->userId, $this->userFolder->getRelativePath($this->file->getPath()));
|
||||||
|
|
||||||
return array_map(function (array $data) {
|
return array_map(function (array $data) {
|
||||||
return new VersionFile($data);
|
return new VersionFile($data, $this->userFolder->getParent());
|
||||||
}, $versions);
|
}, $versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,23 @@ declare(strict_types=1);
|
||||||
namespace OCA\Files_Versions\Sabre;
|
namespace OCA\Files_Versions\Sabre;
|
||||||
|
|
||||||
use OCA\Files_Versions\Storage;
|
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\Forbidden;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
use Sabre\DAV\IFile;
|
use Sabre\DAV\IFile;
|
||||||
|
|
||||||
class VersionFile implements IFile {
|
class VersionFile implements IFile {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $data;
|
private $data;
|
||||||
|
|
||||||
public function __construct(array $data) {
|
/** @var Folder */
|
||||||
|
private $userRoot;
|
||||||
|
|
||||||
|
public function __construct(array $data, Folder $userRoot) {
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
$this->userRoot = $userRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put($data) {
|
public function put($data) {
|
||||||
|
@ -41,7 +48,16 @@ class VersionFile implements IFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get() {
|
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 {
|
public function getContentType(): string {
|
||||||
|
|
Loading…
Reference in New Issue