Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-06-15 11:25:27 +0300
committerJulius Härtl <jus@bitgrid.net>2020-06-15 11:28:18 +0300
commitff1328a695f86ff4833113e86276722dd29a96a3 (patch)
treed830d20ec58641ec774d5438ccf5cc06f51a336d /lib
parentb9f3e6d295a5b834b01801493011a69aefeb82ee (diff)
Perform file conflict check earlier so that it also triggers when not saving
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/DocumentService.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php
index 467dc4c80..73eb53688 100644
--- a/lib/Service/DocumentService.php
+++ b/lib/Service/DocumentService.php
@@ -293,6 +293,15 @@ class DocumentService {
$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;
}
@@ -305,13 +314,6 @@ class DocumentService {
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);