loolwsd/Exceptions.hpp |    6 ++++++
 loolwsd/LOOLWSD.cpp    |   16 ++++++++++++++--
 loolwsd/Storage.cpp    |    6 ++++++
 3 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 5b08fe6477dc18ff9055ad59a28499b9c4264d0a
Author: Tor Lillqvist <t...@collabora.com>
Date:   Fri Sep 30 16:09:53 2016 +0300

    Add handling of dangerously low storage space for local files
    
    Sends the same 'error: cmd=internal kind=diskfull' message as when
    disk space for LOOL's own needs is getting full, but only to the
    user(s) of that document. We can't in general know whether one
    document in the Storage abstraction is located even close to another.

diff --git a/loolwsd/Exceptions.hpp b/loolwsd/Exceptions.hpp
index eb2b4a6..b9839c8 100644
--- a/loolwsd/Exceptions.hpp
+++ b/loolwsd/Exceptions.hpp
@@ -21,6 +21,12 @@ protected:
     using std::runtime_error::runtime_error;
 };
 
+class StorageSpaceLowException : public LoolException
+{
+public:
+    using LoolException::LoolException;
+};
+
 /// A bad-request exception that is meant to signify,
 /// and translate into, an HTTP bad request.
 class BadRequestException : public LoolException
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 7e36a4b..1d0d519 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1181,8 +1181,6 @@ public:
                 }
             }
 
-            docBroker->load(jailId);
-
             auto ws = std::make_shared<WebSocket>(request, response);
             auto session = std::make_shared<PrisonerSession>(sessionId, ws, 
docBroker);
 
@@ -1192,6 +1190,20 @@ public:
                 Log::warn("Failed to connect " + session->getName() + " to its 
peer.");
             }
 
+            try
+            {
+                docBroker->load(jailId);
+            }
+            catch (const StorageSpaceLowException&)
+            {
+                // We use the same message as is sent when some of lool's own 
locations are full,
+                // even if in this case it might be a totally different 
location (file system, or
+                // some other type of storage somewhere). This message is not 
sent to all clients,
+                // though, just to all sessions of this document.
+                docBroker->alertAllUsersOfDocument("internal", "diskfull");
+                throw;
+            }
+
             std::unique_lock<std::mutex> lock(AvailableChildSessionMutex);
             AvailableChildSessions.emplace(sessionId, session);
 
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index 89efd79..f320e2e 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -187,7 +187,13 @@ std::string LocalStorage::loadStorageFileToLocal()
     Log::info("Public URI [" + _uri +
               "] jailed to [" + _jailedFilePath + "].");
 
+    // Despite the talk about URIs it seems that _uri is actually just a 
pathname here
+
     const auto publicFilePath = _uri;
+
+    if (!Util::checkDiskSpace(publicFilePath))
+        throw StorageSpaceLowException("Low disk space for " + publicFilePath);
+
     Log::info("Linking " + publicFilePath + " to " + _jailedFilePath);
     if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), 
_jailedFilePath.c_str()) == -1)
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to