loolwsd/Storage.hpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
New commits: commit 978147df55cfa521e36d79bd22d8c4a94cc1bba9 Author: Ashod Nakashian <ashod.nakash...@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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits