tdf#57414 autorecovery: don't store unmodified docs in RecoveryList
When a document is successfully saved (manually),
it is removed from RecoveryList (implts_markDocumentAsSaved)
and all of the temporary recovery files are removed
from the user's backup folder.
If the document is automatically saved (UserAutoSave)
successfully, it doesn't need to remain in the RecoveryList either.
storeToRecoveryFile can benefit from knowing if it will be removed,
so determine whether to bRemoveIt just prior to that call.
Change-Id: I2cb30b426e600cfe34987a091acaf8826316ede5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155272
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 1071423..816e4f7 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -3096,6 +3096,10 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
else if (xModify.is())
rInfo.DocumentState &= ~DocState::Modified;
// If it is no longer modified, it is the same as on disk, and can be removed from RecoveryList.
const bool bRemoveIt
= xModify.is() && !xModify->isModified() && !bEmergencySave && !(m_eJob & Job::SessionSave);
sal_Int32 nRetry = RETRY_STORE_ON_FULL_DISC_FOREVER;
bool bError = false;
do
@@ -3184,7 +3188,8 @@ void AutoRecovery::implts_saveOneDoc(const OUString&
rInfo.OldTempURL = rInfo.NewTempURL;
rInfo.NewTempURL.clear();
implts_flushConfigItem(rInfo);
// If it is modified, a recovery file has just been created, so add to RecoveryList.
implts_flushConfigItem(rInfo, bRemoveIt, /*bAllowAdd=*/bModified);
// We must know if the user modifies the document again ...
implts_startModifyListeningOnDoc(rInfo);