Skip to content

Commit

Permalink
Move share path setting in sharemodel into separate private method
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
  • Loading branch information
claucambra committed Jul 14, 2023
1 parent 48f1dfa commit 7f1216e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/gui/filedetails/sharemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ void ShareModel::updateData()
qCDebug(lcShareModel) << "Updating share model data now.";

const auto relPath = _localPath.mid(_folder->cleanPath().length() + 1);
const auto sharePath = _folder->remotePathTrailingSlash() + relPath;
const auto percentEncoded = QUrl::toPercentEncoding(sharePath);
_sharePath = QString::fromUtf8(percentEncoded);
updateRelativeSharePath(relPath);

SyncJournalFileRecord fileRecord;
auto resharingAllowed = true; // lets assume the good
Expand Down Expand Up @@ -323,6 +321,13 @@ void ShareModel::updateData()
initShareManager();
}

void ShareModel::updateRelativeSharePath(const QString &relativePath)
{
const auto unsanitisedSharePath = _folder->remotePathTrailingSlash() + relativePath;
const auto sanitisedSharePath = QUrl::toPercentEncoding(unsanitisedSharePath);
_sharePath = QString::fromUtf8(sanitisedSharePath);
}

void ShareModel::initShareManager()
{
if (!_accountState || _accountState->account().isNull()) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/filedetails/sharemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ private slots:
void handleSecureFileDropLinkShare();
void handleLinkShare();
void setupInternalLinkShare();
void updateRelativeSharePath(const QString &relativePath);
void setSharePermissionChangeInProgress(const QString &shareId, const bool isInProgress);
void setHideDownloadEnabledChangeInProgress(const QString &shareId, const bool isInProgress);

Expand Down

0 comments on commit 7f1216e

Please sign in to comment.