From 68fcbbd31c940f99bab37ce80ad89a1e43fabb03 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 28 Feb 2024 16:06:16 +0100 Subject: [PATCH] fix(files_versions): Do not create a new version for empty files Signed-off-by: Louis Chemineau --- apps/files_versions/lib/Listener/FileEventsListener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index 206c75ec6ec39..f199d47b98153 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -218,11 +218,12 @@ public function post_write_hook(Node $node): void { } if ( - ($writeHookInfo['versionCreated'] || $writeHookInfo['previousNode']->getSize() === 0) && + $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. + // If both versions have the same mtime, it means the latest version file simply got overrode, + // so no need to create a new version. $this->created($node); } else { try {