mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-20 23:24:34 +00:00
wsd: Storage logs updated
Change-Id: Ib3083e833fdc2891ab0c89231bf2ec3e81285803 Reviewed-on: https://gerrit.libreoffice.org/32560 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:

committed by
Ashod Nakashian

parent
de4a7a139e
commit
aef5af8114
@ -108,14 +108,14 @@ bool isLocalhost(const std::string& targetHost)
|
|||||||
}
|
}
|
||||||
catch (const Poco::Exception& exc)
|
catch (const Poco::Exception& exc)
|
||||||
{
|
{
|
||||||
Log::warn("Poco::Net::DNS::resolveOne(\"" + targetHost + "\") failed: " + exc.displayText());
|
LOG_WRN("Poco::Net::DNS::resolveOne(\"" << targetHost << "\") failed: " << exc.displayText());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
targetAddress = Poco::Net::IPAddress(targetHost).toString();
|
targetAddress = Poco::Net::IPAddress(targetHost).toString();
|
||||||
}
|
}
|
||||||
catch (const Poco::Exception& exc1)
|
catch (const Poco::Exception& exc1)
|
||||||
{
|
{
|
||||||
Log::warn("Poco::Net::IPAddress(\"" + targetHost + "\") failed: " + exc1.displayText());
|
LOG_WRN("Poco::Net::IPAddress(\"" << targetHost << "\") failed: " << exc1.displayText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ std::atomic<unsigned> LocalStorage::LastLocalStorageId;
|
|||||||
std::unique_ptr<LocalStorage::LocalFileInfo> LocalStorage::getLocalFileInfo(const Poco::URI& uriPublic)
|
std::unique_ptr<LocalStorage::LocalFileInfo> LocalStorage::getLocalFileInfo(const Poco::URI& uriPublic)
|
||||||
{
|
{
|
||||||
const auto path = Poco::Path(uriPublic.getPath());
|
const auto path = Poco::Path(uriPublic.getPath());
|
||||||
Log::debug("Getting info for local uri [" + uriPublic.toString() + "], path [" + path.toString() + "].");
|
LOG_DBG("Getting info for local uri [" << uriPublic.toString() << "], path [" << path.toString() << "].");
|
||||||
|
|
||||||
const auto& filename = path.getFileName();
|
const auto& filename = path.getFileName();
|
||||||
const auto file = Poco::File(path);
|
const auto file = Poco::File(path);
|
||||||
@ -213,7 +213,7 @@ std::string LocalStorage::loadStorageFileToLocal()
|
|||||||
const auto filename = Poco::Path(_uri.getPath()).getFileName();
|
const auto filename = Poco::Path(_uri.getPath()).getFileName();
|
||||||
_jailedFilePath = Poco::Path(rootPath, filename).toString();
|
_jailedFilePath = Poco::Path(rootPath, filename).toString();
|
||||||
LOG_INF("Public URI [" << _uri.getPath() <<
|
LOG_INF("Public URI [" << _uri.getPath() <<
|
||||||
"] jailed to [" + _jailedFilePath + "].");
|
"] jailed to [" << _jailedFilePath << "].");
|
||||||
|
|
||||||
// Despite the talk about URIs it seems that _uri is actually just a pathname here
|
// Despite the talk about URIs it seems that _uri is actually just a pathname here
|
||||||
const auto publicFilePath = _uri.getPath();
|
const auto publicFilePath = _uri.getPath();
|
||||||
@ -227,7 +227,7 @@ std::string LocalStorage::loadStorageFileToLocal()
|
|||||||
if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), _jailedFilePath.c_str()) == -1)
|
if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), _jailedFilePath.c_str()) == -1)
|
||||||
{
|
{
|
||||||
// Failed
|
// Failed
|
||||||
Log::warn("link(\"" + publicFilePath + "\", \"" + _jailedFilePath + "\") failed. Will copy.");
|
LOG_WRN("link(\"" << publicFilePath << "\", \"" << _jailedFilePath << "\") failed. Will copy.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -242,7 +242,7 @@ std::string LocalStorage::loadStorageFileToLocal()
|
|||||||
}
|
}
|
||||||
catch (const Poco::Exception& exc)
|
catch (const Poco::Exception& exc)
|
||||||
{
|
{
|
||||||
Log::error("copyTo(\"" + publicFilePath + "\", \"" + _jailedFilePath + "\") failed: " + exc.displayText());
|
LOG_ERR("copyTo(\"" << publicFilePath << "\", \"" << _jailedFilePath << "\") failed: " << exc.displayText());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ void getWOPIValue(const Poco::JSON::Object::Ptr &object, const std::string& key,
|
|||||||
|
|
||||||
std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Poco::URI& uriPublic)
|
std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Poco::URI& uriPublic)
|
||||||
{
|
{
|
||||||
LOG_DBG("Getting info for wopi uri [" + uriPublic.toString() + "].");
|
LOG_DBG("Getting info for wopi uri [" << uriPublic.toString() << "].");
|
||||||
|
|
||||||
std::string resMsg;
|
std::string resMsg;
|
||||||
const auto startTime = std::chrono::steady_clock::now();
|
const auto startTime = std::chrono::steady_clock::now();
|
||||||
@ -374,13 +374,17 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
|||||||
std::istream& rs = psession->receiveResponse(response);
|
std::istream& rs = psession->receiveResponse(response);
|
||||||
callDuration = (std::chrono::steady_clock::now() - startTime);
|
callDuration = (std::chrono::steady_clock::now() - startTime);
|
||||||
|
|
||||||
|
if (Log::traceEnabled())
|
||||||
|
{
|
||||||
auto logger = Log::trace();
|
auto logger = Log::trace();
|
||||||
logger << "WOPI::CheckFileInfo header for URI [" << uriPublic.toString() << "]:\n";
|
logger << "WOPI::CheckFileInfo header for URI [" << uriPublic.toString() << "]:\n";
|
||||||
for (auto& pair : response)
|
for (const auto& pair : response)
|
||||||
{
|
{
|
||||||
logger << '\t' + pair.first + ": " + pair.second << " / ";
|
logger << '\t' << pair.first << ": " << pair.second << " / ";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger << Log::end;
|
logger << Log::end;
|
||||||
|
}
|
||||||
|
|
||||||
Poco::StreamCopier::copyToString(rs, resMsg);
|
Poco::StreamCopier::copyToString(rs, resMsg);
|
||||||
}
|
}
|
||||||
@ -408,7 +412,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
|||||||
bool disableCopy = false;
|
bool disableCopy = false;
|
||||||
std::string lastModifiedTime;
|
std::string lastModifiedTime;
|
||||||
|
|
||||||
LOG_DBG("WOPI::CheckFileInfo returned: " + resMsg + ". Call duration: " + std::to_string(callDuration.count()) + "s");
|
LOG_DBG("WOPI::CheckFileInfo returned: " << resMsg << ". Call duration: " << callDuration.count() << "s");
|
||||||
const auto index = resMsg.find_first_of('{');
|
const auto index = resMsg.find_first_of('{');
|
||||||
if (index != std::string::npos)
|
if (index != std::string::npos)
|
||||||
{
|
{
|
||||||
@ -433,7 +437,9 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
|||||||
getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
|
getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LOG_ERR("WOPI::CheckFileInfo is missing JSON payload");
|
LOG_ERR("WOPI::CheckFileInfo is missing JSON payload");
|
||||||
|
}
|
||||||
|
|
||||||
Poco::Timestamp modifiedTime = Poco::Timestamp::fromEpochTime(0);
|
Poco::Timestamp modifiedTime = Poco::Timestamp::fromEpochTime(0);
|
||||||
if (lastModifiedTime != "")
|
if (lastModifiedTime != "")
|
||||||
@ -448,12 +454,15 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
|||||||
}
|
}
|
||||||
catch (const Poco::SyntaxException& exc)
|
catch (const Poco::SyntaxException& exc)
|
||||||
{
|
{
|
||||||
LOG_WRN("LastModifiedTime property [" + lastModifiedTime + "] was invalid format: " << exc.displayText() <<
|
LOG_WRN("LastModifiedTime property [" << lastModifiedTime << "] was invalid format: " << exc.displayText() <<
|
||||||
(exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
|
(exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
|
||||||
}
|
}
|
||||||
if (valid)
|
if (valid)
|
||||||
|
{
|
||||||
modifiedTime = dateTime.timestamp();
|
modifiedTime = dateTime.timestamp();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_fileInfo = FileInfo({filename, ownerId, modifiedTime, size});
|
_fileInfo = FileInfo({filename, ownerId, modifiedTime, size});
|
||||||
|
|
||||||
return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, callDuration}));
|
return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, callDuration}));
|
||||||
@ -466,7 +475,7 @@ std::string WopiStorage::loadStorageFileToLocal()
|
|||||||
// Add it here to get the payload instead of file info.
|
// Add it here to get the payload instead of file info.
|
||||||
Poco::URI uriObject(_uri);
|
Poco::URI uriObject(_uri);
|
||||||
uriObject.setPath(uriObject.getPath() + "/contents");
|
uriObject.setPath(uriObject.getPath() + "/contents");
|
||||||
LOG_DBG("Wopi requesting: " + uriObject.toString());
|
LOG_DBG("Wopi requesting: " << uriObject.toString());
|
||||||
|
|
||||||
const auto startTime = std::chrono::steady_clock::now();
|
const auto startTime = std::chrono::steady_clock::now();
|
||||||
try
|
try
|
||||||
@ -482,13 +491,17 @@ std::string WopiStorage::loadStorageFileToLocal()
|
|||||||
const std::chrono::duration<double> diff = (std::chrono::steady_clock::now() - startTime);
|
const std::chrono::duration<double> diff = (std::chrono::steady_clock::now() - startTime);
|
||||||
_wopiLoadDuration += diff;
|
_wopiLoadDuration += diff;
|
||||||
|
|
||||||
|
if (Log::traceEnabled())
|
||||||
|
{
|
||||||
auto logger = Log::trace();
|
auto logger = Log::trace();
|
||||||
logger << "WOPI::GetFile header for URI [" << uriObject.toString() << "]:\n";
|
logger << "WOPI::GetFile header for URI [" << uriObject.toString() << "]:\n";
|
||||||
for (auto& pair : response)
|
for (const auto& pair : response)
|
||||||
{
|
{
|
||||||
logger << '\t' + pair.first + ": " + pair.second << " / ";
|
logger << '\t' << pair.first << ": " << pair.second << " / ";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger << Log::end;
|
logger << Log::end;
|
||||||
|
}
|
||||||
|
|
||||||
_jailedFilePath = Poco::Path(getLocalRootPath(), _fileInfo._filename).toString();
|
_jailedFilePath = Poco::Path(getLocalRootPath(), _fileInfo._filename).toString();
|
||||||
std::ofstream ofs(_jailedFilePath);
|
std::ofstream ofs(_jailedFilePath);
|
||||||
@ -517,6 +530,7 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Poco::URI& uri
|
|||||||
LOG_INF("Uploading URI [" << uriPublic.toString() << "] from [" << _jailedFilePath + "].");
|
LOG_INF("Uploading URI [" << uriPublic.toString() << "] from [" << _jailedFilePath + "].");
|
||||||
// TODO: Check if this URI has write permission (canWrite = true)
|
// TODO: Check if this URI has write permission (canWrite = true)
|
||||||
const auto size = getFileSize(_jailedFilePath);
|
const auto size = getFileSize(_jailedFilePath);
|
||||||
|
|
||||||
Poco::URI uriObject(uriPublic);
|
Poco::URI uriObject(uriPublic);
|
||||||
uriObject.setPath(uriObject.getPath() + "/contents");
|
uriObject.setPath(uriObject.getPath() + "/contents");
|
||||||
LOG_DBG("Wopi posting: " + uriObject.toString());
|
LOG_DBG("Wopi posting: " + uriObject.toString());
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
_fileInfo("", "lool", Poco::Timestamp::fromEpochTime(0), 0),
|
_fileInfo("", "lool", Poco::Timestamp::fromEpochTime(0), 0),
|
||||||
_isLoaded(false)
|
_isLoaded(false)
|
||||||
{
|
{
|
||||||
Log::debug("Storage ctor: " + uri.toString());
|
LOG_DBG("Storage ctor: " << uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getLocalRootPath() const;
|
std::string getLocalRootPath() const;
|
||||||
@ -123,11 +123,12 @@ public:
|
|||||||
StorageBase(uri, localStorePath, jailPath),
|
StorageBase(uri, localStorePath, jailPath),
|
||||||
_isCopy(false)
|
_isCopy(false)
|
||||||
{
|
{
|
||||||
Log::info("LocalStorage ctor with localStorePath: [" + localStorePath +
|
LOG_INF("LocalStorage ctor with localStorePath: [" << localStorePath <<
|
||||||
"], jailPath: [" + jailPath + "], uri: [" + uri.toString() + "].");
|
"], jailPath: [" << jailPath << "], uri: [" << uri.toString() << "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalFileInfo {
|
class LocalFileInfo
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
LocalFileInfo(const std::string& userid,
|
LocalFileInfo(const std::string& userid,
|
||||||
const std::string& username)
|
const std::string& username)
|
||||||
@ -165,8 +166,8 @@ public:
|
|||||||
StorageBase(uri, localStorePath, jailPath),
|
StorageBase(uri, localStorePath, jailPath),
|
||||||
_wopiLoadDuration(0)
|
_wopiLoadDuration(0)
|
||||||
{
|
{
|
||||||
Log::info("WopiStorage ctor with localStorePath: [" + localStorePath +
|
LOG_INF("WopiStorage ctor with localStorePath: [" << localStorePath <<
|
||||||
"], jailPath: [" + jailPath + "], uri: [" + uri.toString() + "].");
|
"], jailPath: [" << jailPath << "], uri: [" << uri.toString() << "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
class WOPIFileInfo
|
class WOPIFileInfo
|
||||||
@ -254,8 +255,8 @@ public:
|
|||||||
StorageBase(uri, localStorePath, jailPath),
|
StorageBase(uri, localStorePath, jailPath),
|
||||||
_authAgent(std::move(authAgent))
|
_authAgent(std::move(authAgent))
|
||||||
{
|
{
|
||||||
Log::info("WebDAVStorage ctor with localStorePath: [" + localStorePath +
|
LOG_INF("WebDAVStorage ctor with localStorePath: [" << localStorePath <<
|
||||||
"], jailPath: [" + jailPath + "], uri: [" + uri.toString() + "].");
|
"], jailPath: [" << jailPath << "], uri: [" << uri.toString() << "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement me
|
// Implement me
|
||||||
|
Reference in New Issue
Block a user