wsd: pass WopiFileInfo optionally to addSession

This is to allow for having gotten the WopiFileInfo
before creating DocBroker at all.

Change-Id: I0f21442860e09385e504b9a98049af286cc5b404
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2023-05-20 06:50:34 -04:00 committed by Michael Meeks
parent fdf43d682a
commit 8afdc40aca
2 changed files with 18 additions and 10 deletions

View file

@ -754,7 +754,9 @@ void DocumentBroker::stop(const std::string& reason)
_poll->wakeup();
}
bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, const std::string& jailId)
bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session,
const std::string& jailId,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo)
{
ASSERT_CORRECT_THREAD();
@ -836,8 +838,8 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con
{
LOG_DBG("CheckFileInfo for docKey [" << _docKey << ']');
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo =
wopiStorage->getWOPIFileInfo(session->getAuthorization(), *_lockCtx);
if (!wopiFileInfo)
wopiFileInfo = wopiStorage->getWOPIFileInfo(session->getAuthorization(), *_lockCtx);
checkFileInfoCallDurationMs = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start);
@ -2630,11 +2632,12 @@ std::string DocumentBroker::getJailRoot() const
return Poco::Path(COOLWSD::ChildRoot, _jailId).toString();
}
std::size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session)
std::size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo)
{
try
{
return addSessionInternal(session);
return addSessionInternal(session, std::move(wopiFileInfo));
}
catch (const std::exception& exc)
{
@ -2649,14 +2652,16 @@ std::size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& ses
}
}
std::size_t DocumentBroker::addSessionInternal(const std::shared_ptr<ClientSession>& session)
std::size_t
DocumentBroker::addSessionInternal(const std::shared_ptr<ClientSession>& session,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo)
{
ASSERT_CORRECT_THREAD();
try
{
// First, download the document, since this can fail.
if (!download(session, _childProcess->getJailId()))
if (!download(session, _childProcess->getJailId(), std::move(wopiFileInfo)))
{
const auto msg = "Failed to load document with URI [" + session->getPublicUri().toString() + "].";
LOG_ERR(msg);

View file

@ -404,7 +404,8 @@ public:
std::string getJailRoot() const;
/// Add a new session. Returns the new number of sessions.
std::size_t addSession(const std::shared_ptr<ClientSession>& session);
std::size_t addSession(const std::shared_ptr<ClientSession>& session,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo = nullptr);
/// Removes a session by ID. Returns the new number of sessions.
std::size_t removeSession(const std::shared_ptr<ClientSession>& session);
@ -570,7 +571,8 @@ private:
void refreshLock();
/// Loads a document from the public URI into the jail.
bool download(const std::shared_ptr<ClientSession>& session, const std::string& jailId);
bool download(const std::shared_ptr<ClientSession>& session, const std::string& jailId,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo);
bool isLoaded() const { return _docState.hadLoaded(); }
bool isInteractive() const { return _docState.isInteractive(); }
@ -761,7 +763,8 @@ private:
std::size_t countActiveSessions() const;
/// Loads a new session and adds to the sessions container.
std::size_t addSessionInternal(const std::shared_ptr<ClientSession>& session);
std::size_t addSessionInternal(const std::shared_ptr<ClientSession>& session,
std::unique_ptr<WopiStorage::WOPIFileInfo> wopiFileInfo);
/// Starts the Kit <-> DocumentBroker shutdown handshake
void disconnectSessionInternal(const std::shared_ptr<ClientSession>& session);