[Pkg-owncloud-commits] [owncloud-client] 64/332: CSync: Fetch permissions from server for whole tree on server update
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:38 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 8dbfcd782b6bbf5983006572ed69de3ba73d4e9c
Author: Markus Goetz <markus at woboq.com>
Date: Fri Jun 6 17:05:55 2014 +0200
CSync: Fetch permissions from server for whole tree on server update
---
csync/src/csync_owncloud_util.c | 7 +++++++
csync/src/csync_update.c | 12 ++++++++++++
src/mirall/syncengine.cpp | 2 +-
src/mirall/syncjournaldb.cpp | 2 +-
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/csync/src/csync_owncloud_util.c b/csync/src/csync_owncloud_util.c
index 628dc44..1e84ca8 100644
--- a/csync/src/csync_owncloud_util.c
+++ b/csync/src/csync_owncloud_util.c
@@ -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
}
}
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index d9c88e2..adc7785 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -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) */
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index d16f4f7..d3b55fa 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -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;
}
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 41ff6b7..edb88d5 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list