mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #52373 from nextcloud/fix/files-version-creation
fix(files_versions): create version if previous does not exist
This commit is contained in:
commit
0051db7a43
1 changed files with 11 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue