[Libreoffice-commits] online.git: wsd/Storage.cpp
Tor Lillqvist
tml at collabora.com
Fri Dec 16 13:32:12 UTC 2016
wsd/Storage.cpp | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
New commits:
commit 20f8c8d65a8830f6b4ab806b128182f592cce255
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Dec 16 15:19:27 2016 +0200
Use also the LastModifiedTime property from the WOPI CheckFileInfo response
If not present, set the FileInfo _modifiedTime to the UNIX epoch.
Change-Id: I2e805d34e426368e5319cb9321159c21fe8ae9e0
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 585711f..d0e1fca 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -15,10 +15,12 @@
#include <fstream>
#include <string>
+#include <Poco/DateTime.h>
+#include <Poco/DateTimeParser.h>
+#include <Poco/Exception.h>
#include <Poco/JSON/Object.h>
#include <Poco/JSON/Parser.h>
#include <Poco/Net/DNS.h>
-#include <Poco/Exception.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
@@ -26,6 +28,7 @@
#include <Poco/Net/NetworkInterface.h>
#include <Poco/Net/SSLManager.h>
#include <Poco/StreamCopier.h>
+#include <Poco/Timestamp.h>
#include "Auth.hpp"
#include "Common.hpp"
@@ -393,6 +396,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
bool disablePrint = false;
bool disableExport = false;
bool disableCopy = false;
+ std::string lastModifiedTime;
std::string resMsg;
Poco::StreamCopier::copyToString(rs, resMsg);
@@ -420,14 +424,33 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
getWOPIValue(object, "DisablePrint", disablePrint);
getWOPIValue(object, "DisableExport", disableExport);
getWOPIValue(object, "DisableCopy", disableCopy);
+ getWOPIValue(object, "LastModifiedTime", lastModifiedTime);
}
else
Log::error("WOPI::CheckFileInfo is missing JSON payload");
if (!_fileInfo.isValid())
{
- // WOPI doesn't support file last modified time.
- _fileInfo = FileInfo({filename, ownerId, Poco::Timestamp(), size});
+ Poco::Timestamp modifiedTime = Poco::Timestamp::fromEpochTime(0);
+ if (lastModifiedTime != "")
+ {
+ Poco::DateTime dateTime;
+ int timeZoneDifferential;
+ bool valid = false;
+ try
+ {
+ Poco::DateTimeParser::parse(Poco::DateTimeFormat::ISO8601_FRAC_FORMAT, lastModifiedTime, dateTime, timeZoneDifferential);
+ valid = true;
+ }
+ catch (const Poco::SyntaxException& exc)
+ {
+ LOG_WRN("LastModifiedTime property [" + lastModifiedTime + "] was invalid format: " << exc.displayText() <<
+ (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
+ }
+ if (valid)
+ modifiedTime = dateTime.timestamp();
+ }
+ _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}));
More information about the Libreoffice-commits
mailing list