aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-12-08 17:44:09 +0100
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>2023-01-26 10:12:23 +0000
commit84e5b9c5f7646303ca9f5070187c8464cde0bd30 (patch)
treee0f003fddfcdb8f387cee59f90feab026feece49
parent6dcfb29cfc83cbec2e3d990088c88321b5572cab (diff)
downloadnextcloud-server-84e5b9c5f7646303ca9f5070187c8464cde0bd30.tar.gz
nextcloud-server-84e5b9c5f7646303ca9f5070187c8464cde0bd30.zip
Prevent storing versions with the same mtime
Signed-off-by: Louis Chemineau <louis@chmn.me>
-rw-r--r--apps/files_versions/lib/Listener/FileEventsListener.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php
index b3694459ac6..98dbce17e96 100644
--- a/apps/files_versions/lib/Listener/FileEventsListener.php
+++ b/apps/files_versions/lib/Listener/FileEventsListener.php
@@ -208,8 +208,9 @@ class FileEventsListener implements IEventListener {
return;
}
- if ($writeHookInfo['versionCreated']) {
+ if ($writeHookInfo['versionCreated'] && $node->getMTime() !== $writeHookInfo['previousNode']->getMTime()) {
// If a new version was created, insert a version in the DB for the current content.
+ // Unless both versions have the same mtime.
$versionEntity = new VersionEntity();
$versionEntity->setFileId($node->getId());
$versionEntity->setTimestamp($node->getMTime());
@@ -227,7 +228,7 @@ class FileEventsListener implements IEventListener {
$this->versionsMapper->update($currentVersionEntity);
}
- unset($this->versionsCreated[$node->getId()]);
+ unset($this->writeHookInfo[$node->getId()]);
}
/**