[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 13 08:04:41 UTC 2019
wsd/DocumentBroker.cpp | 11 ++++++++---
wsd/DocumentBroker.hpp | 3 +++
wsd/LOOLWSD.cpp | 9 +++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
New commits:
commit 81932fdadce3f59dfbaaf06d45b7be9addad839b
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue May 21 19:50:17 2019 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Jun 13 10:04:22 2019 +0200
tdf#123482 - cleanup convert-to folder even more reliably.
Problems could occur if exceptiosn thrown when parsing the input stream.
Change-Id: Id82b3816450194164fc2093554c730b4a94acef1
Reviewed-on: https://gerrit.libreoffice.org/72695
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/72744
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 73a43c4b2..b2eabd655 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1932,13 +1932,18 @@ ConvertToBroker::ConvertToBroker(const std::string& uri,
ConvertToBroker::~ConvertToBroker()
{
NumConverters--;
- if (!_uriOrig.empty())
+ removeFile(_uriOrig);
+}
+
+void ConvertToBroker::removeFile(const std::string &uriOrig)
+{
+ if (!uriOrig.empty())
{
// Remove source file and directory
- Poco::Path path = _uriOrig;
+ Poco::Path path = uriOrig;
Poco::File(path).remove();
Poco::File(path.makeParent()).remove();
- FileUtil::removeFile(_uriOrig);
+ FileUtil::removeFile(uriOrig);
}
}
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 9521f2eca..55216a0a9 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -484,6 +484,9 @@ public:
/// How many live conversions are running.
static size_t getInstanceCount();
+
+ /// Cleanup path and its parent
+ static void removeFile(const std::string &uri);
};
#endif
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ef0a013c..90659923a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -570,6 +570,9 @@ class ConvertToPartHandler : public PartHandler
public:
std::string getFilename() const { return _filename; }
+ /// Afterwards someone else is responsible for cleaning that up.
+ void takeFile() { _filename.clear(); }
+
ConvertToPartHandler(bool convertTo = false)
: _convertTo(convertTo)
{
@@ -577,6 +580,11 @@ public:
virtual ~ConvertToPartHandler()
{
+ if (!_filename.empty())
+ {
+ LOG_TRC("Remove un-handled temporary file '" << _filename << "'");
+ ConvertToBroker::removeFile(_filename);
+ }
}
virtual void handlePart(const MessageHeader& header, std::istream& stream) override
@@ -2371,6 +2379,7 @@ private:
LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
auto docBroker = std::make_shared<ConvertToBroker>(fromPath, uriPublic, docKey);
+ handler.takeFile();
cleanupDocBrokers();
More information about the Libreoffice-commits
mailing list