Skip to content

Commit 0b1f71a

Browse files
committed
fix(files_versions): Do not create a new version for empty files
Signed-off-by: Louis Chemineau <[email protected]>
1 parent f2f1074 commit 0b1f71a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/files_versions/lib/Listener/FileEventsListener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,12 @@ public function post_write_hook(Node $node): void {
219219
}
220220

221221
if (
222-
($writeHookInfo['versionCreated'] || $writeHookInfo['previousNode']->getSize() === 0) &&
222+
$writeHookInfo['versionCreated'] &&
223223
$node->getMTime() !== $writeHookInfo['previousNode']->getMTime()
224224
) {
225225
// If a new version was created, insert a version in the DB for the current content.
226-
// Unless both versions have the same mtime.
226+
// If both versions have the same mtime, it means the latest version file simply got overrode,
227+
// so no need to create a new version.
227228
$this->created($node);
228229
} else {
229230
try {

0 commit comments

Comments
 (0)