Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ public function autosave($file, $documentId, $version, $autoaveDocument, $force
$savedEtag = $file->getEtag();
$lastMTime = $document->getLastSavedVersionTime();

if ($lastMTime > 0 && $savedEtag !== $document->getLastSavedVersionEtag() && $force === false) {
if (!$this->cache->get('document-save-lock-' . $documentId)) {
throw new DocumentSaveConflictException('File changed in the meantime from outside');
} else {
// Only return here if the document is locked, otherwise we can continue to save
return $document;
}
}

if ($autoaveDocument === null) {
return $document;
}
Expand All @@ -305,13 +314,6 @@ public function autosave($file, $documentId, $version, $autoaveDocument, $force
if ($file->getMTime() === $lastMTime && $lastMTime > time() - self::AUTOSAVE_MINIMUM_DELAY && $manualSave === false) {
return $document;
}
if ($lastMTime > 0 && $savedEtag !== $document->getLastSavedVersionEtag() && $force === false) {
if (!$this->cache->get('document-save-lock-' . $documentId)) {
throw new DocumentSaveConflictException('File changed in the meantime from outside');
} else {
return $document;
}
}
$this->cache->set('document-save-lock-' . $documentId, true, 10);
try {
$file->putContent($autoaveDocument);
Expand Down