mirror of
https://github.com/nextcloud/server.git
synced 2026-04-23 23:27:46 -04:00
fix: Avoid failing to update the current version entry if there is none
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
c015089d46
commit
e045faa6a7
1 changed files with 12 additions and 5 deletions
|
|
@ -239,11 +239,18 @@ class FileEventsListener implements IEventListener {
|
|||
} else {
|
||||
// If no new version was stored in the FS, no new version should be added in the DB.
|
||||
// So we simply update the associated version.
|
||||
$currentVersionEntity = $this->versionsMapper->findVersionForFileId($node->getId(), $writeHookInfo['previousNode']->getMtime());
|
||||
$currentVersionEntity->setTimestamp($node->getMTime());
|
||||
$currentVersionEntity->setSize($node->getSize());
|
||||
$currentVersionEntity->setMimetype($this->mimeTypeLoader->getId($node->getMimetype()));
|
||||
$this->versionsMapper->update($currentVersionEntity);
|
||||
try {
|
||||
$currentVersionEntity = $this->versionsMapper->findVersionForFileId($node->getId(), $writeHookInfo['previousNode']->getMtime());
|
||||
$currentVersionEntity->setTimestamp($node->getMTime());
|
||||
$currentVersionEntity->setSize($node->getSize());
|
||||
$currentVersionEntity->setMimetype($this->mimeTypeLoader->getId($node->getMimetype()));
|
||||
$this->versionsMapper->update($currentVersionEntity);
|
||||
} catch (DoesNotExistException) {
|
||||
// There might be cases where the current version entry doesn't exist,
|
||||
// e.g. if none was written due to an empty file or from before the versions table was introduced
|
||||
// We just create the initial version entry then for the current entity
|
||||
$this->created($node);
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->writeHookInfo[$node->getId()]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue