[Pkg-owncloud-commits] [owncloud-client] 118/484: csync_update: Don't fetch the etag in the local discovery from the DB

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:27 UTC 2015


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 9c388787bbe99a4fa0ae5038e8c5bdb0356ab92e
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Wed Oct 21 14:17:30 2015 +0200

    csync_update: Don't fetch the etag in the local discovery from the DB
    
    We don't need it, and it's slow.
    This saves a lot of DB queries
    
    (Also replaced a strlen>0 with a faster check)
---
 csync/src/csync_statedb.c  | 22 ----------------------
 csync/src/csync_update.c   | 29 -----------------------------
 src/libsync/syncengine.cpp |  8 ++++----
 test/testcsyncsqlite.h     | 10 ----------
 4 files changed, 4 insertions(+), 65 deletions(-)

diff --git a/csync/src/csync_statedb.c b/csync/src/csync_statedb.c
index f12e0b1..92ca528 100644
--- a/csync/src/csync_statedb.c
+++ b/csync/src/csync_statedb.c
@@ -416,28 +416,6 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
   return st;
 }
 
-/* Get the etag. */
-char *csync_statedb_get_etag( CSYNC *ctx, uint64_t jHash ) {
-    char *ret = NULL;
-    csync_file_stat_t *fs = NULL;
-
-    if( !ctx ) {
-        return NULL;
-    }
-
-    if( ! csync_get_statedb_exists(ctx)) return ret;
-
-    fs = csync_statedb_get_stat_by_hash(ctx, jHash );
-    if( fs ) {
-        if( fs->etag ) {
-            ret = c_strdup(fs->etag);
-        }
-        csync_file_stat_free(fs);
-    }
-
-    return ret;
-}
-
 #define BELOW_PATH_QUERY "SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm, filesize, ignoredChildrenRemote FROM metadata WHERE pathlen>? AND path LIKE(?)"
 
 int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 99570c2..4eb0457 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -270,10 +270,6 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
                   ((int64_t) fs->mtime), ((int64_t) tmp->modtime),
                   fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode,
                   (uint64_t) fs->size, (uint64_t) tmp->size, fs->remotePerm, tmp->remotePerm, tmp->has_ignored_files );
-        if( !fs->etag) {
-            st->instruction = CSYNC_INSTRUCTION_EVAL;
-            goto out;
-        }
         if((ctx->current == REMOTE_REPLICA && !c_streq(fs->etag, tmp->etag ))
             || (ctx->current == LOCAL_REPLICA && (!_csync_mtime_equal(fs->mtime, tmp->modtime)
                                                   // zero size in statedb can happen during migration
@@ -772,31 +768,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
       flag = CSYNC_FTW_FLAG_NSTAT;
     }
 
-    if( ctx->current == LOCAL_REPLICA ) {
-        char *etag = NULL;
-        int len = strlen( path );
-        uint64_t h = c_jhash64((uint8_t *) path, len, 0);
-        etag = csync_statedb_get_etag( ctx, h );
-
-        if(_last_db_return_error(ctx)) {
-            ctx->status_code = CSYNC_STATUS_UNSUCCESSFUL;
-            SAFE_FREE(etag);
-            goto error;
-        }
-
-        if( etag ) {
-            SAFE_FREE(fs->etag);
-            fs->etag = etag;
-            fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_ETAG;
-
-            if( c_streq(etag, "")) {
-                CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID from Database is EMPTY: %s", path);
-            } else {
-                CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID from Database: %s -> %s", path, fs->etag ? fs->etag : "<NULL>" );
-            }
-        }
-    }
-
     previous_fs = ctx->current_fs;
 
     /* Call walker function for each file */
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index ca2f8ff..0588364 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -341,7 +341,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
         }
     }
 
-    if (file->file_id && strlen(file->file_id) > 0) {
+    if (file->file_id && file->file_id[0]) {
         item->_fileId = file->file_id;
     }
     if (file->directDownloadUrl) {
@@ -431,9 +431,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
 
     item->_isDirectory = file->type == CSYNC_FTW_TYPE_DIR;
 
-    // The etag is already set in the previous sync phases somewhere. Maybe we should remove it there
-    // and do it here so we have a consistent state about which tree stores information from which source.
-    item->_etag = file->etag;
+    if (file->etag && file->etag[0]) {
+        item->_etag = file->etag;
+    }
     item->_size = file->size;
 
     if (!remote) {
diff --git a/test/testcsyncsqlite.h b/test/testcsyncsqlite.h
index 01b886b..be7b556 100644
--- a/test/testcsyncsqlite.h
+++ b/test/testcsyncsqlite.h
@@ -81,16 +81,6 @@ private slots:
         csync_file_stat_free(st);
     }
 
-    void testEtag() {
-        char *etag = csync_statedb_get_etag((CSYNC*)(&_ctx), 7145399680328529363 );
-        QCOMPARE( QString::fromUtf8(etag), QLatin1String("52847f208be09"));
-        SAFE_FREE(etag);
-
-        etag = csync_statedb_get_etag((CSYNC*)(&_ctx), -8148768149813301136);
-        QCOMPARE( QString::fromUtf8(etag), QLatin1String("530d148493894"));
-        SAFE_FREE(etag);
-    }
-
     void cleanupTestCase() {
         SAFE_FREE(_ctx.statedb.file);
         csync_statedb_close((CSYNC*)(&_ctx));

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