[Pkg-owncloud-commits] [owncloud-client] 82/103: Csync: Plug code for csync_file_locked_or_open

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Apr 30 18:09:02 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 7f752c7e93e864d666501c0634ec81f1f48a4df5
Author: Markus Goetz <markus at woboq.com>
Date:   Mon Apr 28 16:57:56 2014 +0200

    Csync: Plug code for csync_file_locked_or_open
---
 csync/src/csync.h           |  3 ++-
 csync/src/csync_reconcile.c | 10 ++++++++++
 csync/src/csync_util.c      | 12 +++++++++---
 csync/src/csync_util.h      |  3 +--
 src/mirall/syncengine.cpp   |  4 ++++
 5 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/csync/src/csync.h b/csync/src/csync.h
index 49f3979..7438a29 100644
--- a/csync/src/csync.h
+++ b/csync/src/csync.h
@@ -102,7 +102,8 @@ enum csync_status_codes_e {
     /* Codes for file individual status: */
     CSYNC_STATUS_INDIVIDUAL_IS_SYMLINK,
     CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST,
-    CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS
+    CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS,
+    CYSNC_STATUS_FILE_LOCKED_OR_OPEN
 };
 
 typedef enum csync_status_codes_e CSYNC_STATUS;
diff --git a/csync/src/csync_reconcile.c b/csync/src/csync_reconcile.c
index 5d3e3ab..649b322 100644
--- a/csync/src/csync_reconcile.c
+++ b/csync/src/csync_reconcile.c
@@ -223,6 +223,16 @@ static int _csync_merge_algorithm_visitor(void *obj, void *data) {
         /* file on current replica is changed or new */
         case CSYNC_INSTRUCTION_EVAL:
         case CSYNC_INSTRUCTION_NEW:
+            // This operation is usually a no-op and will by default return false
+            if (csync_file_locked_or_open(ctx->local.uri, cur->path)) {
+                CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "[Reconciler] IGNORING file %s/%s since it is locked / open", ctx->local.uri, cur->path);
+                cur->instruction = CSYNC_INSTRUCTION_ERROR;
+                if (cur->error_status == CSYNC_STATUS_OK) // don't overwrite error
+                    cur->error_status = CYSNC_STATUS_FILE_LOCKED_OR_OPEN;
+                break;
+            } else {
+                //CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "[Reconciler] not ignoring file %s/%s", ctx->local.uri, cur->path);
+            }
             switch (other->instruction) {
             /* file on other replica is changed or new */
             case CSYNC_INSTRUCTION_NEW:
diff --git a/csync/src/csync_util.c b/csync/src/csync_util.c
index 3381533..7d02adb 100644
--- a/csync/src/csync_util.c
+++ b/csync/src/csync_util.c
@@ -182,8 +182,14 @@ csync_vio_file_stat_t *csync_vio_convert_file_stat(csync_file_stat_t *st) {
 }
 
 bool (*csync_file_locked_or_open_ext) (const char*) = 0; // filled in by library user
-bool csync_file_locked_or_open( const char *file) {
-    if (!csync_file_locked_or_open_ext)
+bool csync_file_locked_or_open( const char *dir, const char *fname) {
+    CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "csync_file_locked_or_open %p %s/%s", csync_file_locked_or_open_ext, dir, fname);
+    if (!csync_file_locked_or_open_ext) {
         return false;
-    return csync_file_locked_or_open_ext(file);
+    }
+    char *tmp_uri = NULL;
+    asprintf(&tmp_uri, "%s/%s", dir, fname);
+    bool ret = csync_file_locked_or_open_ext(tmp_uri);
+    SAFE_FREE(tmp_uri);
+    return ret;
 }
diff --git a/csync/src/csync_util.h b/csync/src/csync_util.h
index 700332c..20fe694 100644
--- a/csync/src/csync_util.h
+++ b/csync/src/csync_util.h
@@ -35,6 +35,5 @@ void csync_win32_set_file_hidden( const char *file, bool hidden );
 /* Convert a csync_file_stat_t to csync_vio_file_stat_t */
 csync_vio_file_stat_t *csync_vio_convert_file_stat(csync_file_stat_t *st);
 
-bool csync_file_locked_or_open( const char *file);
-
+bool csync_file_locked_or_open( const char *dir, const char *fname);
 #endif /* _CSYNC_UTIL_H */
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index 930eed9..95338e7 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -177,6 +177,9 @@ QString SyncEngine::csyncErrorToString(CSYNC_STATUS err)
     case CSYNC_STATUS_ABORTED:
         errStr = tr("Aborted by the user");
         break;
+    case CYSNC_STATUS_FILE_LOCKED_OR_OPEN:
+        errStr = "File locked"; // don't translate, internal use!
+        break;
 
     default:
         errStr = tr("An internal error number %1 happened.").arg( (int) err );
@@ -279,6 +282,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
     case CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS:
         item._errorString = tr("File contains invalid characters that can not be synced cross platform.");
         break;
+
     default:
         Q_ASSERT("Non handled error-status");
         /* No error string */

-- 
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