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-16 11:03:00 +0300
committerGitHub <noreply@github.com>2020-06-16 11:03:00 +0300
commitf5cfa9abe63e693a4107f8549f70bc60be68f4c1 (patch)
tree604b5e1c2763198581ad7095ad51460163194ca4 /lib
parentff0a0960b40031a6d5d568dc6d78218cf3751dd5 (diff)
parentff1328a695f86ff4833113e86276722dd29a96a3 (diff)
Merge pull request #871 from nextcloud/bugfix/851
Perform file conflict check earlier so that it also triggers when not saving
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);