[Libreoffice-commits] online.git: loolwsd/DocumentBroker.hpp loolwsd/Storage.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Mar 23 00:04:32 UTC 2016
loolwsd/DocumentBroker.hpp | 13 +------------
loolwsd/Storage.hpp | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 12 deletions(-)
New commits:
commit cf3811a7fb2a87489c44d80b0de36af00d102af4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Mar 21 08:31:07 2016 -0400
loolwsd: refactored storage construction into factory
Change-Id: I5e1453b100d852424b472d08746d8636b7656755
Reviewed-on: https://gerrit.libreoffice.org/23451
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index ac59213..3f7c75e 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -101,18 +101,7 @@ public:
Log::info("jailPath: " + jailPath.toString() + ", jailRoot: " + jailRoot);
- if (_uriPublic.isRelative() || _uriPublic.getScheme() == "file")
- {
- Log::info("Public URI [" + _uriPublic.toString() + "] is a file.");
- _storage.reset(new LocalStorage(jailRoot, jailPath.toString(), _uriPublic.getPath()));
- }
- else
- {
- Log::info("Public URI [" + _uriPublic.toString() +
- "] assuming cloud storage.");
- //TODO: Configure the storage to use. For now, assume it's WOPI.
- _storage.reset(new WopiStorage(jailRoot, jailPath.toString(), _uriPublic.toString()));
- }
+ _storage = createStorage(jailRoot, jailPath.toString(), _uriPublic);
const auto localPath = _storage->loadStorageFileToLocal();
_uriJailed = Poco::URI(Poco::URI("file://"), localPath);
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index 4fe14af..edc8569 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -262,5 +262,22 @@ private:
std::unique_ptr<AuthBase> _authAgent;
};
+inline
+std::unique_ptr<StorageBase> createStorage(const std::string& jailRoot, const std::string& jailPath, const Poco::URI& uri)
+{
+ if (uri.isRelative() || uri.getScheme() == "file")
+ {
+ Log::info("Public URI [" + uri.toString() + "] is a file.");
+ return std::unique_ptr<StorageBase>(new LocalStorage(jailRoot, jailPath, uri.getPath()));
+ }
+ else
+ {
+ Log::info("Public URI [" + uri.toString() +
+ "] assuming cloud storage.");
+ //TODO: Configure the storage to use. For now, assume it's WOPI.
+ return std::unique_ptr<StorageBase>(new WopiStorage(jailRoot, jailPath, uri.toString()));
+ }
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list