diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-06-16 11:03:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 11:03:00 +0300 |
commit | f5cfa9abe63e693a4107f8549f70bc60be68f4c1 (patch) | |
tree | 604b5e1c2763198581ad7095ad51460163194ca4 /lib | |
parent | ff0a0960b40031a6d5d568dc6d78218cf3751dd5 (diff) | |
parent | ff1328a695f86ff4833113e86276722dd29a96a3 (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.php | 16 |
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); |