Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we don't enter empty permissions to the db #8076

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/8076
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix missing permission for newly created folder

We fixed a bug where a newly created folder had no permissions set.

https://github.com/owncloud/client/pull/8076
2 changes: 1 addition & 1 deletion src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ bool SyncJournalDb::setFileRecord(const SyncJournalFileRecord &_record)
}
}
}

OC_ASSERT(!record._remotePerm.isNull());
qCInfo(lcDb) << "Updating file record for path:" << record._path << "inode:" << record._inode
<< "modtime:" << record._modtime << "type:" << record._type
<< "etag:" << record._etag << "fileId:" << record._fileId << "remotePerm:" << record._remotePerm.toString()
Expand Down
46 changes: 14 additions & 32 deletions src/libsync/propagateremotemkdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,38 +106,20 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()

_item->_fileId = _job->reply()->rawHeader("OC-FileId");

if (_item->_fileId.isEmpty()) {
// Owncloud 7.0.0 and before did not have a header with the file id.
// (https://github.com/owncloud/core/issues/9000)
// So we must get the file id using a PROPFIND
// This is required so that we can detect moves even if the folder is renamed on the server
// while files are still uploading
propagator()->_activeJobList.append(this);
auto propfindJob = new PropfindJob(_job->account(), _job->path(), this);
propfindJob->setProperties(QList<QByteArray>() << "http://owncloud.org/ns:id");
QObject::connect(propfindJob, &PropfindJob::result, this, &PropagateRemoteMkdir::propfindResult);
QObject::connect(propfindJob, &PropfindJob::finishedWithError, this, &PropagateRemoteMkdir::propfindError);
propfindJob->start();
_job = propfindJob;
return;
}
success();
}

void PropagateRemoteMkdir::propfindResult(const QVariantMap &result)
{
propagator()->_activeJobList.removeOne(this);
if (result.contains(QStringLiteral("id"))) {
_item->_fileId = result[QStringLiteral("id")].toByteArray();
}
success();
}

void PropagateRemoteMkdir::propfindError()
{
// ignore the PROPFIND error
propagator()->_activeJobList.removeOne(this);
done(SyncFileItem::Success);
propagator()->_activeJobList.append(this);
auto propfindJob = new PropfindJob(_job->account(), _job->path(), this);
propfindJob->setProperties({"http://owncloud.org/ns:permissions"});
connect(propfindJob, &PropfindJob::result, this, [this](const QVariantMap &result){
propagator()->_activeJobList.removeOne(this);
_item->_remotePerm = RemotePermissions::fromServerString(result.value(QStringLiteral("permissions")).toString());
success();
});
connect(propfindJob, &PropfindJob::finishedWithError, this, [this]{
// ignore the PROPFIND error
propagator()->_activeJobList.removeOne(this);
done(SyncFileItem::NormalError);
});
propfindJob->start();
}

void PropagateRemoteMkdir::success()
Expand Down
2 changes: 0 additions & 2 deletions src/libsync/propagateremotemkdir.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class PropagateRemoteMkdir : public PropagateItemJob
private slots:
void slotStartMkcolJob();
void slotMkcolJobFinished();
void propfindResult(const QVariantMap &);
void propfindError();
void success();
};
}
4 changes: 3 additions & 1 deletion test/testsyncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private slots:
{
SyncJournalFileRecord record;
record._path = "foo-nochecksum";
record._remotePerm = RemotePermissions();
record._remotePerm = RemotePermissions::fromDbValue("RW");
record._modtime = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());

QVERIFY(_db.setFileRecord(record));
Expand Down Expand Up @@ -201,6 +201,7 @@ private slots:
record._path = path;
record._type = type;
record._etag = initialEtag;
record._remotePerm = RemotePermissions::fromDbValue("RW");
_db.setFileRecord(record);
};
auto getEtag = [&](const QByteArray &path) {
Expand Down Expand Up @@ -265,6 +266,7 @@ private slots:
auto makeEntry = [&](const QByteArray &path) {
SyncJournalFileRecord record;
record._path = path;
record._remotePerm = RemotePermissions::fromDbValue("RW");
_db.setFileRecord(record);
};

Expand Down