[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Mar 1 21:43:05 UTC 2019
wsd/ClientSession.cpp | 5 -----
wsd/DocumentBroker.cpp | 13 +++++++++++++
wsd/DocumentBroker.hpp | 18 ++++++++++++++++--
wsd/LOOLWSD.cpp | 3 ++-
4 files changed, 31 insertions(+), 8 deletions(-)
New commits:
commit 2d473222e4cad399b131345395d6506b26e0e134
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Mar 1 22:25:44 2019 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Mar 1 22:34:29 2019 +0100
tdf#123482 - cleanup convert-to folder more reliably.
Change-Id: I029bb4136984e05485e462c92da80b92b00fdebc
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 49623636a..c0a02b806 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -856,11 +856,6 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
// Now terminate.
docBroker->stop("Finished saveas handler.");
-
- // Remove file and directory
- Poco::Path path = docBroker->getDocKey();
- Poco::File(path).remove();
- Poco::File(path.makeParent()).remove();
}
return true;
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 974fe7f3c..8f058bd2c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -37,6 +37,7 @@
#include <common/Message.hpp>
#include <common/Protocol.hpp>
#include <common/Unit.hpp>
+#include <common/FileUtil.hpp>
#include <sys/types.h>
#include <sys/wait.h>
@@ -1850,6 +1851,18 @@ void DocumentBroker::getIOStats(uint64_t &sent, uint64_t &recv)
}
}
+ConvertToBroker::~ConvertToBroker()
+{
+ if (!_uriOrig.empty())
+ {
+ // Remove source file and directory
+ Poco::Path path = _uriOrig;
+ Poco::File(path).remove();
+ Poco::File(path.makeParent()).remove();
+ FileUtil::removeFile(_uriOrig);
+ }
+}
+
void DocumentBroker::dumpState(std::ostream& os)
{
std::unique_lock<std::mutex> lock(_mutex);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 46c300df1..bde8b24e4 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -223,7 +223,7 @@ public:
const Poco::URI& uriPublic,
const std::string& docKey);
- ~DocumentBroker();
+ virtual ~DocumentBroker();
/// Start processing events
void startThread();
@@ -400,8 +400,9 @@ private:
/// Sum the I/O stats from all connected sessions
void getIOStats(uint64_t &sent, uint64_t &recv);
-private:
+protected:
const std::string _uriOrig;
+private:
const Poco::URI _uriPublic;
/// URL-based key. May be repeated during the lifetime of WSD.
const std::string _docKey;
@@ -469,6 +470,19 @@ private:
static std::atomic<unsigned> DocBrokerId;
};
+class ConvertToBroker : public DocumentBroker
+{
+public:
+ /// Construct DocumentBroker with URI and docKey
+ ConvertToBroker(const std::string& uri,
+ const Poco::URI& uriPublic,
+ const std::string& docKey)
+ : DocumentBroker(uri, uriPublic, docKey)
+ {
+ }
+ virtual ~ConvertToBroker();
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 26321eead..b135fd6bf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -593,6 +593,7 @@ public:
if (!params.has("filename"))
return;
+ // FIXME: needs wrapping - until then - keep in sync with ~ConvertToBroker
Path tempPath = _convertTo? Path::forDirectory(Poco::TemporaryFile::tempName("/tmp/convert-to") + "/") :
Path::forDirectory(Poco::TemporaryFile::tempName() + "/");
File(tempPath).createDirectories();
@@ -2365,7 +2366,7 @@ private:
std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
- auto docBroker = std::make_shared<DocumentBroker>(fromPath, uriPublic, docKey);
+ auto docBroker = std::make_shared<ConvertToBroker>(fromPath, uriPublic, docKey);
cleanupDocBrokers();
More information about the Libreoffice-commits
mailing list