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.
This commit is contained in:
Tor Lillqvist 2016-09-30 16:09:53 +03:00
parent 3090981c8a
commit 5b08fe6477
3 changed files with 26 additions and 2 deletions

View file

@ -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

View file

@ -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);

View file

@ -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)
{