Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ public function pre_touch_hook(Node $node): void {
}

public function touch_hook(Node $node): void {
// Do not handle folders.
if ($node instanceof Folder) {
return;
}

if ($node instanceof NonExistingFile) {
$this->logger->error(
'Failed to create or update version for {path}, node does not exist',
[
'path' => $node->getPath(),
]
);

return;
}

$previousNode = $this->nodesTouched[$node->getId()] ?? null;

if ($previousNode === null) {
Expand Down Expand Up @@ -152,7 +168,22 @@ public function touch_hook(Node $node): void {

public function created(Node $node): void {
// Do not handle folders.
if ($node instanceof File && $this->versionManager instanceof INeedSyncVersionBackend) {
if (!($node instanceof File)) {
return;
}

if ($node instanceof NonExistingFile) {
$this->logger->error(
'Failed to create version for {path}, node does not exist',
[
'path' => $node->getPath(),
]
);

return;
}

if ($this->versionManager instanceof INeedSyncVersionBackend) {
$this->versionManager->createVersionEntity($node);
}
}
Expand Down Expand Up @@ -190,6 +221,17 @@ public function post_write_hook(Node $node): void {
return;
}

if ($node instanceof NonExistingFile) {
$this->logger->error(
'Failed to create or update version for {path}, node does not exist',
[
'path' => $node->getPath(),
]
);

return;
}

$writeHookInfo = $this->writeHookInfo[$node->getId()] ?? null;

if ($writeHookInfo === null) {
Expand Down
Loading