aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_versions/lib/Listener/FileEventsListener.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php
index 49150f4e726..c581c61b4ae 100644
--- a/apps/files_versions/lib/Listener/FileEventsListener.php
+++ b/apps/files_versions/lib/Listener/FileEventsListener.php
@@ -196,8 +196,8 @@ class FileEventsListener implements IEventListener {
}
if (
- $writeHookInfo['versionCreated'] &&
- $node->getMTime() !== $writeHookInfo['previousNode']->getMTime()
+ $writeHookInfo['versionCreated']
+ && $node->getMTime() !== $writeHookInfo['previousNode']->getMTime()
) {
// If a new version was created, insert a version in the DB for the current content.
// If both versions have the same mtime, it means the latest version file simply got overrode,
@@ -218,6 +218,15 @@ class FileEventsListener implements IEventListener {
],
);
}
+ } catch (DoesNotExistException $e) {
+ // This happens if the versions app was not enabled while the file was created or updated the last time.
+ // meaning there is no such revision and we need to create this file.
+ if ($writeHookInfo['versionCreated']) {
+ $this->created($node);
+ } else {
+ // Normally this should not happen so we re-throw the exception to not hide any potential issues.
+ throw $e;
+ }
} catch (Exception $e) {
$this->logger->error('Failed to update existing version for ' . $node->getPath(), [
'exception' => $e,