summaryrefslogtreecommitdiffstats
path: root/wsd/DocumentBroker.cpp
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2022-01-25 08:45:30 -0500
committerPranam Lashkari <plashkari628@gmail.com>2022-01-26 15:33:15 +0530
commit9e5b9d6d37bf4ed5675b50ba9b5823812ddb7c89 (patch)
tree2ef9cf6fe1d506dc306cea39357a4ef48c739b0f /wsd/DocumentBroker.cpp
parentmake sure modifiedTimeUs calculates with enough precision (diff)
downloadonline-9e5b9d6d37bf4ed5675b50ba9b5823812ddb7c89.tar.gz
online-9e5b9d6d37bf4ed5675b50ba9b5823812ddb7c89.zip
wsd: support PDF comment saving during unload with test
PDFs are view_comment type documents where editing is not supported, but adding comments are. This means that we do get ModifiedStatus=true but we never get ModifiedStatus=false after .uno:Save. This is because the save command is handled in a special way in Core by invoking save-as instead, which doesn't reset the ModifiedStatus. The issue with this was that DocBroker was stuck on trying to save the document before unloading, thinking it was modified due to the stuck ModifiedStatus. Here, we change the definition of isPossiblyModified() to ignore the ModifiedStatus for such documents. Instead, we rely on the last save being successful and that no new user input exists past the last save request. In addition, we now have a new Cypress test that reproduced the failure without the fix and now passes with the fix. Change-Id: Ida9d486ac93a588b9007c5e4583d8bf3c090a62d Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'wsd/DocumentBroker.cpp')
-rw-r--r--wsd/DocumentBroker.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index ef7a8febc5..9906121a1d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -122,6 +122,7 @@ DocumentBroker::DocumentBroker(ChildType type,
_docKey(docKey),
_docId(Util::encodeId(DocBrokerId++, 3)),
_documentChangedInStorage(false),
+ _isViewFileExtension(false),
_isModified(false),
_cursorPosX(0),
_cursorPosY(0),
@@ -641,9 +642,10 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con
watermarkText = wopifileinfo->getWatermarkText();
templateSource = wopifileinfo->getTemplateSource();
+ _isViewFileExtension = COOLWSD::IsViewFileExtension(wopiStorage->getFileExtension());
if (CommandControl::FreemiumManager::isFreemiumReadOnlyUser() ||
!wopifileinfo->getUserCanWrite() ||
- COOLWSD::IsViewFileExtension(wopiStorage->getFileExtension()))
+ _isViewFileExtension)
{
LOG_DBG("Setting the session as readonly");
session->setReadOnly();
@@ -1204,6 +1206,7 @@ void DocumentBroker::checkAndUploadToStorage(const std::string& sessionId, bool
break;
}
+ // Avoid multiple uploads during unloading if we know we need to save a new version.
if (_docState.isUnloadRequested() && isPossiblyModified())
{
// We are unloading but have possible modifications. Save again (done in poll).
@@ -1866,6 +1869,7 @@ void DocumentBroker::autoSaveAndStop(const std::string& reason)
<< "] before terminating.");
if (!autoSave(isPossiblyModified()))
{
+ // Nothing to save. Try to upload if necessary.
const std::string sessionId = getWriteableSessionId();
if (!sessionId.empty())
{
@@ -1880,6 +1884,10 @@ void DocumentBroker::autoSaveAndStop(const std::string& reason)
}
}
}
+ else if (!canStop)
+ {
+ LOG_TRC("Too soon to issue another save on [" << getDocKey() << ']');
+ }
if (canStop)
{