]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files_versions): Do not create a new version for empty files 43896/head
authorLouis Chemineau <louis@chmn.me>
Wed, 28 Feb 2024 15:06:16 +0000 (16:06 +0100)
committerLouis <louis@chmn.me>
Thu, 29 Feb 2024 20:32:28 +0000 (21:32 +0100)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/files_versions/lib/Listener/FileEventsListener.php

index f5def37fc9eb428493036fc514cbdfce2a15f784..84cffc2c1fd64a4cb3ea4b353f71a254f95892df 100644 (file)
@@ -219,11 +219,12 @@ class FileEventsListener implements IEventListener {
                }
 
                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 {