summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/Sabre/VersionFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions/lib/Sabre/VersionFile.php')
-rw-r--r--apps/files_versions/lib/Sabre/VersionFile.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/apps/files_versions/lib/Sabre/VersionFile.php b/apps/files_versions/lib/Sabre/VersionFile.php
index b7c7e6db1a6..20ae25a7623 100644
--- a/apps/files_versions/lib/Sabre/VersionFile.php
+++ b/apps/files_versions/lib/Sabre/VersionFile.php
@@ -26,6 +26,9 @@ declare(strict_types=1);
*/
namespace OCA\Files_Versions\Sabre;
+use OCA\Files_Versions\Versions\IDeletableVersionBackend;
+use OCA\Files_Versions\Versions\INameableVersion;
+use OCA\Files_Versions\Versions\INameableVersionBackend;
use OCA\Files_Versions\Versions\IVersion;
use OCA\Files_Versions\Versions\IVersionManager;
use OCP\Files\NotFoundException;
@@ -70,7 +73,11 @@ class VersionFile implements IFile {
}
public function delete() {
- throw new Forbidden();
+ if ($this->versionManager instanceof IDeletableVersionBackend) {
+ $this->versionManager->deleteVersion($this->version);
+ } else {
+ throw new Forbidden();
+ }
}
public function getName(): string {
@@ -81,6 +88,23 @@ class VersionFile implements IFile {
throw new Forbidden();
}
+ public function getLabel(): ?string {
+ if ($this->version instanceof INameableVersion && $this->version->getSourceFile()->getSize() > 0) {
+ return $this->version->getLabel();
+ } else {
+ return null;
+ }
+ }
+
+ public function setLabel($label): bool {
+ if ($this->versionManager instanceof INameableVersionBackend) {
+ $this->versionManager->setVersionLabel($this->version, $label);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public function getLastModified(): int {
return $this->version->getTimestamp();
}