quarantine: quarantine file on loading

additionals:
make sure quarantine does not fail on the exit

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I8843ba7e72dc3703c1168b57c9927598bfa5d1f7
This commit is contained in:
Pranam Lashkari 2021-11-20 20:23:23 +05:30 committed by Pranam Lashkari
parent 2c6846270e
commit 4aeaafee98

View file

@ -950,7 +950,9 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con
_uriJailedAnonym = Poco::URI(Poco::URI("file://"), COOLWSD::anonymizeUrl(localPathEncoded)).toString();
_filename = fileInfo.getFilename();
#if !MOBILEAPP
Quarantine::quarantineFile(this, _filename);
#endif
if (!templateSource.empty())
{
// Invalid timestamp for templates, to force uploading once we save-after-loading.
@ -1123,7 +1125,6 @@ void DocumentBroker::handleSaveResponse(const std::string& sessionId, bool succe
const std::string oldName = _storage->getRootFilePathToUpload();
const std::string newName = _storage->getRootFilePathUploading();
Quarantine::quarantineFile(this, _storage->getFileInfo().getFilename() + TO_UPLOAD_SUFFIX);
if (rename(oldName.c_str(), newName.c_str()) < 0)
{
@ -1137,6 +1138,8 @@ void DocumentBroker::handleSaveResponse(const std::string& sessionId, bool succe
{
LOG_TRC("Renamed [" << oldName << "] to [" << newName << ']');
}
Quarantine::quarantineFile(this, Util::splitLast(newName, '/').second);
#endif //!MOBILEAPP
// Record that we got a response to avoid timing out on saving.