Skip to content

Commit cd3c969

Browse files
committed
Perform file conflict check earlier so that it also triggers when not saving
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent b9f3e6d commit cd3c969

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/Service/DocumentService.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ public function autosave($file, $documentId, $version, $autoaveDocument, $force
293293
$savedEtag = $file->getEtag();
294294
$lastMTime = $document->getLastSavedVersionTime();
295295

296+
if ($lastMTime > 0 && $savedEtag !== $document->getLastSavedVersionEtag() && $force === false) {
297+
if (!$this->cache->get('document-save-lock-' . $documentId)) {
298+
throw new DocumentSaveConflictException('File changed in the meantime from outside');
299+
}
300+
return $document;
301+
}
302+
296303
if ($autoaveDocument === null) {
297304
return $document;
298305
}
@@ -305,13 +312,6 @@ public function autosave($file, $documentId, $version, $autoaveDocument, $force
305312
if ($file->getMTime() === $lastMTime && $lastMTime > time() - self::AUTOSAVE_MINIMUM_DELAY && $manualSave === false) {
306313
return $document;
307314
}
308-
if ($lastMTime > 0 && $savedEtag !== $document->getLastSavedVersionEtag() && $force === false) {
309-
if (!$this->cache->get('document-save-lock-' . $documentId)) {
310-
throw new DocumentSaveConflictException('File changed in the meantime from outside');
311-
} else {
312-
return $document;
313-
}
314-
}
315315
$this->cache->set('document-save-lock-' . $documentId, true, 10);
316316
try {
317317
$file->putContent($autoaveDocument);

0 commit comments

Comments
 (0)