[Libreoffice-commits] online.git: loolwsd/Storage.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Mar 9 02:33:57 UTC 2016
loolwsd/Storage.hpp | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
New commits:
commit 978147df55cfa521e36d79bd22d8c4a94cc1bba9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Tue Mar 8 19:21:16 2016 -0500
loolwsd: refactored path manipulation in Storage.
Change-Id: I320c5638353b03df4fd0be612bb66c26e4f498a3
Reviewed-on: https://gerrit.libreoffice.org/23052
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index efda920..8fcf773 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -34,6 +34,22 @@ public:
{
}
+ std::string getRootPath() const
+ {
+ auto localPath = _jailPath;
+ if (localPath[0] == '/')
+ {
+ // Remove the leading /
+ localPath.erase(0, 1);
+ }
+
+ // /chroot/jailId/user/doc/childId
+ const auto rootPath = Poco::Path(_localStorePath, localPath);
+ Poco::File(rootPath).createDirectories();
+
+ return rootPath.toString();
+ }
+
/// Returns a local file path given a URI or ID.
/// If necessary copies the file locally first.
virtual std::string getFilePathFromURI(const std::string& uri) = 0;
@@ -58,16 +74,7 @@ public:
std::string getFilePathFromURI(const std::string& uri) override
{
- auto localPath = _jailPath;
- if (localPath[0] == '/')
- {
- // Remove the leading /
- localPath.erase(0, 1);
- }
-
- // /chroot/jailId/user/doc/childId
- const auto rootPath = Poco::Path(_localStorePath, localPath);
- Poco::File(rootPath).createDirectories();
+ const auto rootPath = getRootPath();
// /chroot/jailId/user/doc/childId/file.ext
const auto filename = Poco::Path(uri).getFileName();
More information about the Libreoffice-commits
mailing list