[Pkg-owncloud-commits] [owncloud-client] 83/159: Discovery: Speed up initial run. #2796
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri May 1 13:05:26 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 adcf40afc33228f8c187adbca83dd0ff41a8e33d
Author: Christian Kamm <kamm at incasoftware.de>
Date: Wed Apr 8 15:30:07 2015 +0200
Discovery: Speed up initial run. #2796
---
csync/src/csync.c | 10 ++--------
csync/src/csync.h | 5 -----
csync/src/csync_private.h | 12 +++++++++++-
csync/src/csync_statedb.c | 8 ++++----
csync/src/csync_update.c | 2 +-
src/libsync/syncengine.cpp | 8 ++++++--
6 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/csync/src/csync.c b/csync/src/csync.c
index 2390eaa..65a0655 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -576,7 +576,8 @@ int csync_commit(CSYNC *ctx) {
_csync_clean_ctx(ctx);
ctx->remote.read_from_db = 0;
- ctx->read_from_db_disabled = 0;
+ ctx->read_remote_from_db = true;
+ ctx->db_is_empty = false;
/* Create new trees */
@@ -773,10 +774,3 @@ int csync_set_module_property(CSYNC* ctx, const char* key, void* value)
#endif
}
-
-int csync_set_read_from_db(CSYNC* ctx, int enabled)
-{
- ctx->read_from_db_disabled = !enabled;
- return 0;
-}
-
diff --git a/csync/src/csync.h b/csync/src/csync.h
index 85a4bfb..f227c78 100644
--- a/csync/src/csync.h
+++ b/csync/src/csync.h
@@ -550,11 +550,6 @@ void csync_resume(CSYNC *ctx);
*/
int csync_abort_requested(CSYNC *ctx);
-/**
- * Specify if it is allowed to read the remote tree from the DB (default to enabled)
- */
-int csync_set_read_from_db(CSYNC* ctx, int enabled);
-
char *csync_normalize_etag(const char *);
time_t oc_httpdate_parse( const char *date );
diff --git a/csync/src/csync_private.h b/csync/src/csync_private.h
index 7a4e2a5..8552bf3 100644
--- a/csync/src/csync_private.h
+++ b/csync/src/csync_private.h
@@ -151,7 +151,17 @@ struct csync_s {
int status;
volatile int abort;
void *rename_info;
- int read_from_db_disabled;
+
+ /**
+ * Specify if it is allowed to read the remote tree from the DB (default to enabled)
+ */
+ bool read_remote_from_db;
+
+ /**
+ * If true, the DB is considered empty and all reads are skipped. (default is false)
+ * This is useful during the initial local discovery as it speeds it up significantly.
+ */
+ bool db_is_empty;
struct csync_owncloud_ctx_s *owncloud_context;
diff --git a/csync/src/csync_statedb.c b/csync/src/csync_statedb.c
index 1f82e8c..1ba406f 100644
--- a/csync/src/csync_statedb.c
+++ b/csync/src/csync_statedb.c
@@ -298,7 +298,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx,
csync_file_stat_t *st = NULL;
int rc;
- if( !ctx ) {
+ if( !ctx || ctx->db_is_empty ) {
return NULL;
}
@@ -341,7 +341,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx,
return 0;
}
- if( !ctx ) {
+ if( !ctx || ctx->db_is_empty ) {
return NULL;
}
@@ -381,7 +381,7 @@ csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx,
return NULL;
}
- if( !ctx ) {
+ if( !ctx || ctx->db_is_empty ) {
return NULL;
}
@@ -448,7 +448,7 @@ int csync_statedb_get_below_path( CSYNC *ctx, const char *path ) {
return -1;
}
- if( !ctx ) {
+ if( !ctx || ctx->db_is_empty ) {
return -1;
}
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index fdb6df9..1c89a87 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -306,7 +306,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
|| !c_streq(fs->remotePerm, tmp->remotePerm)))
|| (ctx->current == LOCAL_REPLICA && fs->inode != tmp->inode);
if (type == CSYNC_FTW_TYPE_DIR && ctx->current == REMOTE_REPLICA
- && !metadata_differ && !ctx->read_from_db_disabled) {
+ && !metadata_differ && ctx->read_remote_from_db) {
/* If both etag and file id are equal for a directory, read all contents from
* the database.
* The metadata comparison ensure that we fetch all the file id or permission when
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index b9ef9c4..d8fa74a 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -608,11 +608,15 @@ void SyncEngine::startSync()
if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5;
// Disable the read from DB to be sure to re-read all the fileid and etags.
- csync_set_read_from_db(_csync_ctx, false);
+ _csync_ctx->read_remote_from_db = false;
} else {
- csync_set_read_from_db(_csync_ctx, true);
+ _csync_ctx->read_remote_from_db = true;
}
+ // This tells csync to never read from the DB if it is empty
+ // thereby speeding up the initial discovery significantly.
+ _csync_ctx->db_is_empty = (fileRecordCount == 0);
+
bool usingSelectiveSync = (!_selectiveSyncBlackList.isEmpty());
qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");
if (fileRecordCount >= 0 && fileRecordCount < 50 && !usingSelectiveSync) {
--
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