Skip to content

Commit

Permalink
Merge pull request #6742 from nextcloud/bugfix/lockownertype-setreado…
Browse files Browse the repository at this point in the history
…nly-basedoncaps

Bugfix/lockownertype setreadonly basedoncaps
  • Loading branch information
allexzander committed May 12, 2024
2 parents 7bd2b8a + 04c0125 commit 7a49312
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
}

if (item->_type == CSyncEnums::ItemTypeVirtualFile) {
if (item->_locked == SyncFileItem::LockStatus::LockedItem && (item->_lockOwnerType != SyncFileItem::LockOwnerType::TokenLock || item->_lockOwnerId != account()->davUser())) {
const auto lockOwnerTypeToSkipReadonly = _account->capabilities().filesLockTypeAvailable()
? SyncFileItem::LockOwnerType::TokenLock
: SyncFileItem::LockOwnerType::UserLock;
if (item->_locked == SyncFileItem::LockStatus::LockedItem
&& (item->_lockOwnerType != lockOwnerTypeToSkipReadonly || item->_lockOwnerId != account()->davUser())) {
qCDebug(lcEngine()) << filePath << "file is locked: making it read only";
FileSystem::setFileReadOnly(filePath, true);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/syncfileitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ SyncFileItemPtr SyncFileItem::fromProperties(const QString &filePath, const QMap
const auto intConvertedValue = properties.value(QStringLiteral("lock-timeout")).toULongLong(&ok);
item->_lockTimeout = ok ? intConvertedValue : 0;
}

const auto date = QDateTime::fromString(properties.value(QStringLiteral("getlastmodified")), Qt::RFC2822Date);
const auto lastModifiedValue = properties.value(QStringLiteral("getlastmodified")).replace("GMT", "+0000");
const auto date = QDateTime::fromString(lastModifiedValue, Qt::RFC2822Date);
Q_ASSERT(date.isValid());
if (date.toSecsSinceEpoch() > 0) {
item->_modtime = date.toSecsSinceEpoch();
Expand Down

0 comments on commit 7a49312

Please sign in to comment.