CSync: Fetch permissions from server for whole tree on server update

This commit is contained in:
Markus Goetz 2014-06-06 17:05:55 +02:00
parent 70ff928381
commit 8dbfcd782b
4 changed files with 21 additions and 2 deletions

View File

@ -375,6 +375,13 @@ void fill_webdav_properties_into_resource(struct resource* newres, const ne_prop
}
if (perm && strlen(perm) < sizeof(newres->remotePerm)) {
strncpy(newres->remotePerm, perm, sizeof(newres->remotePerm));
} else if (perm && strlen(perm) == 0) {
// special meaning for our code: server returned permissions but are empty
// meaning only reading is allowed for this resource
newres->remotePerm[0] = ' ';
// see _csync_detect_update()
} else {
// old server, keep NULL in newres->remotePerm
}
}

View File

@ -264,7 +264,19 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Reading from database: %s", path);
ctx->remote.read_from_db = true;
}
if (ctx->current == REMOTE_REPLICA
// DB perm; true for NULL or empty (on update)
&& strlen(tmp->remotePerm) == 0
// remote perm (even if remote perm empty it will be ' ' see fill_webdav_properties_into_resource
&& strlen(fs->remotePerm) > 0)
{
/* remotePerm received from server but none in DB.
* Which means we need to update the DB.
* (upgrade from owncloud x to owncloud 7 for instence) */
st->should_update_etag = true; // write to DB after PROPFIND
ctx->remote.read_from_db = false; // get dirs via PROPFIND
}
if (!c_streq(fs->file_id, tmp->file_id) && ctx->current == REMOTE_REPLICA) {
/* file id has changed. Which means we need to update the DB.
* (upgrade from owncloud 5 to owncloud 6 for instence) */

View File

@ -324,7 +324,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
switch(file->instruction) {
case CSYNC_INSTRUCTION_NONE:
if (file->should_update_etag && !item._isDirectory) {
// Update the database now already (new fileid or etag)
// Update the database now already (new fileid or etag or remotePerm)
_journal->setFileRecord(SyncJournalFileRecord(item, _localPath + item._file));
item._should_update_etag = false;
}

View File

@ -385,7 +385,7 @@ bool SyncJournalDb::setFileRecord( const SyncJournalFileRecord& record )
QString fileId( record._fileId);
if( fileId.isEmpty() ) fileId = "";
QString remotePerm (record._remotePerm);
if (remotePerm.isEmpty()) remotePerm = "";
if (remotePerm.isEmpty()) remotePerm = QString(); // have NULL in DB (vs empty)
_setFileRecordQuery->bindValue(0, QString::number(phash));
_setFileRecordQuery->bindValue(1, plen);