Skip to content

Commit 05acd91

Browse files
committed
Base versions' has-preview on mimetype
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 505a11b commit 05acd91

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

apps/files_versions/lib/Sabre/Plugin.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828

2929
use OC\AppFramework\Http\Request;
3030
use OCA\DAV\Connector\Sabre\FilesPlugin;
31-
use OCA\Files_Versions\Versions\IVersionManager;
32-
use OCP\Files\NotFoundException;
31+
use OCP\IPreview;
3332
use OCP\IRequest;
34-
use OCP\IUserSession;
3533
use Sabre\DAV\Exception\NotFound;
3634
use Sabre\DAV\INode;
3735
use Sabre\DAV\PropFind;
@@ -48,8 +46,7 @@ class Plugin extends ServerPlugin {
4846

4947
public function __construct(
5048
private IRequest $request,
51-
private IVersionManager $versionManager,
52-
private IUserSession $userSession,
49+
private IPreview $previewManager,
5350
) {
5451
$this->request = $request;
5552
}
@@ -94,25 +91,9 @@ public function afterGet(RequestInterface $request, ResponseInterface $response)
9491
}
9592

9693
public function propFind(PropFind $propFind, INode $node): void {
97-
$user = $this->userSession->getUser();
98-
9994
if ($node instanceof VersionFile) {
10095
$propFind->handle(self::VERSION_LABEL, fn() => $node->getLabel());
101-
102-
if ($user !== null) {
103-
$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node, $user) {
104-
try {
105-
$this->versionManager->getVersionFile(
106-
$user,
107-
$node->getSourceFile(),
108-
$node->getVersion()->getRevisionId()
109-
);
110-
return true;
111-
} catch (NotFoundException $ex) {
112-
return false;
113-
}
114-
});
115-
}
96+
$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => $this->previewManager->isMimeSupported($node->getContentType()));
11697
}
11798
}
11899

apps/files_versions/lib/Sabre/VersionFile.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ public function get() {
6161
}
6262
}
6363

64-
public function getSourceFile(): FileInfo {
65-
return $this->version->getSourceFile();
66-
}
67-
6864
public function getContentType(): string {
6965
return $this->version->getMimeType();
7066
}

0 commit comments

Comments
 (0)