loolwsd/DocumentBroker.hpp | 13 +------------ loolwsd/Storage.hpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-)
New commits: commit cf3811a7fb2a87489c44d80b0de36af00d102af4 Author: Ashod Nakashian <ashod.nakash...@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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits