[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/Storage.cpp wsd/Storage.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 29 07:43:33 UTC 2018
wsd/DocumentBroker.cpp | 18 +++++++++---------
wsd/Storage.cpp | 12 ++++++------
wsd/Storage.hpp | 17 ++++++++++++-----
3 files changed, 27 insertions(+), 20 deletions(-)
New commits:
commit ae3fec55d41bde6c8e7e50986ae388880a58d87a
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Nov 29 08:42:43 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 29 08:43:02 2018 +0100
StorageBase::FileInfo: make members private
Which shows that the _size member was unused.
Change-Id: Ic6e74659050b86cd9057971ec21623fad75f0c39
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fed34213e..8235c073c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -526,7 +526,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
if (wopifileinfo->getDisableExport())
wopifileinfo->setHideExportOption(true);
- wopiInfo->set("BaseFileName", wopiStorage->getFileInfo()._filename);
+ wopiInfo->set("BaseFileName", wopiStorage->getFileInfo().getFilename());
wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
@@ -551,7 +551,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
session->sendMessage("wopi: " + wopiInfoString);
// Mark the session as 'Document owner' if WOPI hosts supports it
- if (userId == _storage->getFileInfo()._ownerId)
+ if (userId == _storage->getFileInfo().getOwnerId())
{
LOG_DBG("Session [" << sessionId << "] is the document owner");
session->setDocumentOwner(true);
@@ -604,21 +604,21 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
if (firstInstance)
{
- _documentLastModifiedTime = fileInfo._modifiedTime;
+ _documentLastModifiedTime = fileInfo.getModifiedTime();
LOG_DBG("Document timestamp: " << _documentLastModifiedTime);
}
else
{
// Check if document has been modified by some external action
- LOG_TRC("Document modified time: " << fileInfo._modifiedTime);
+ LOG_TRC("Document modified time: " << fileInfo.getModifiedTime());
static const Poco::Timestamp Zero(Poco::Timestamp::fromEpochTime(0));
if (_documentLastModifiedTime != Zero &&
- fileInfo._modifiedTime != Zero &&
- _documentLastModifiedTime != fileInfo._modifiedTime)
+ fileInfo.getModifiedTime() != Zero &&
+ _documentLastModifiedTime != fileInfo.getModifiedTime())
{
LOG_DBG("Document " << _docKey << "] has been modified behind our back. " <<
"Informing all clients. Expected: " << _documentLastModifiedTime <<
- ", Actual: " << fileInfo._modifiedTime);
+ ", Actual: " << fileInfo.getModifiedTime());
_documentChangedInStorage = true;
std::string message = "close: documentconflict";
@@ -703,7 +703,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
_uriJailed = Poco::URI(Poco::URI("file://"), localPathEncoded).toString();
_uriJailedAnonym = Poco::URI(Poco::URI("file://"), LOOLWSD::anonymizeUrl(localPath)).toString();
- _filename = fileInfo._filename;
+ _filename = fileInfo.getFilename();
// Use the local temp file's timestamp.
_lastFileModifiedTime = Poco::File(_storage->getRootFilePath()).getLastModified();
@@ -840,7 +840,7 @@ bool DocumentBroker::saveToStorageInternal(const std::string& sessionId,
_lastSaveTime = std::chrono::steady_clock::now();
// Save the storage timestamp.
- _documentLastModifiedTime = _storage->getFileInfo()._modifiedTime;
+ _documentLastModifiedTime = _storage->getFileInfo().getModifiedTime();
// After a successful save, we are sure that document in the storage is same as ours
_documentChangedInStorage = false;
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 7ed86bc3c..b40bebfb3 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -350,8 +350,8 @@ StorageBase::SaveResult LocalStorage::saveLocalFileToStorage(const Authorization
// update its fileinfo object. This is used later to check if someone else changed the
// document while we are/were editing it
- getFileInfo()._modifiedTime = Poco::File(getUri().getPath()).getLastModified();
- LOG_TRC("New FileInfo modified time in storage " << getFileInfo()._modifiedTime);
+ getFileInfo().setModifiedTime(Poco::File(getUri().getPath()).getLastModified());
+ LOG_TRC("New FileInfo modified time in storage " << getFileInfo().getModifiedTime());
}
catch (const Poco::Exception& exc)
{
@@ -660,7 +660,7 @@ std::string WopiStorage::loadStorageFileToLocal(const Authorization& auth)
}
else // Successful
{
- setRootFilePath(Poco::Path(getLocalRootPath(), getFileInfo()._filename).toString());
+ setRootFilePath(Poco::Path(getLocalRootPath(), getFileInfo().getFilename()).toString());
setRootFilePathAnonym(LOOLWSD::anonymizeUrl(getRootFilePath()));
std::ofstream ofs(getRootFilePath());
std::copy(std::istreambuf_iterator<char>(rs),
@@ -672,7 +672,7 @@ std::string WopiStorage::loadStorageFileToLocal(const Authorization& auth)
setLoaded(true);
// Now return the jailed path.
- return Poco::Path(getJailPath(), getFileInfo()._filename).toString();
+ return Poco::Path(getJailPath(), getFileInfo().getFilename()).toString();
}
}
catch (const Poco::Exception& pexc)
@@ -722,7 +722,7 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization&
{
// Request WOPI host to not overwrite if timestamps mismatch
request.set("X-LOOL-WOPI-Timestamp",
- Poco::DateTimeFormatter::format(Poco::DateTime(getFileInfo()._modifiedTime),
+ Poco::DateTimeFormatter::format(Poco::DateTime(getFileInfo().getModifiedTime()),
Poco::DateTimeFormat::ISO8601_FRAC_FORMAT));
}
}
@@ -824,7 +824,7 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization&
{
const std::string lastModifiedTime = JsonUtil::getJSONValue<std::string>(object, "LastModifiedTime");
LOG_TRC(wopiLog << " returns LastModifiedTime [" << lastModifiedTime << "].");
- getFileInfo()._modifiedTime = iso8601ToTimestamp(lastModifiedTime, "LastModifiedTime");
+ getFileInfo().setModifiedTime(iso8601ToTimestamp(lastModifiedTime, "LastModifiedTime"));
if (isSaveAs)
{
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 39ee3f036..990a03adc 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -34,11 +34,10 @@ public:
FileInfo(const std::string& filename,
const std::string& ownerId,
const Poco::Timestamp& modifiedTime,
- size_t size)
+ size_t /*size*/)
: _filename(filename),
_ownerId(ownerId),
- _modifiedTime(modifiedTime),
- _size(size)
+ _modifiedTime(modifiedTime)
{
}
@@ -48,10 +47,18 @@ public:
return !_filename.empty();
}
+ const std::string& getFilename() const { return _filename; }
+
+ const std::string& getOwnerId() const { return _ownerId; }
+
+ void setModifiedTime(const Poco::Timestamp& modifiedTime) { _modifiedTime = modifiedTime; }
+
+ const Poco::Timestamp& getModifiedTime() const { return _modifiedTime; }
+
+ private:
std::string _filename;
std::string _ownerId;
Poco::Timestamp _modifiedTime;
- size_t _size;
};
class SaveResult
@@ -176,7 +183,7 @@ public:
/// Returns the basic information about the file.
FileInfo& getFileInfo() { return _fileInfo; }
- std::string getFileExtension() const { return Poco::Path(_fileInfo._filename).getExtension(); }
+ std::string getFileExtension() const { return Poco::Path(_fileInfo.getFilename()).getExtension(); }
/// Returns a local file path for the given URI.
/// If necessary copies the file locally first.
More information about the Libreoffice-commits
mailing list