Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/csync
diff options
context:
space:
mode:
authorChristian Kamm <kamm@incasoftware.de>2015-04-08 16:30:07 +0300
committerChristian Kamm <kamm@incasoftware.de>2015-04-08 16:43:49 +0300
commitadcf40afc33228f8c187adbca83dd0ff41a8e33d (patch)
tree0014560f56f5bf00b0ee4619d50fa0a71de091b0 /csync
parentd986011067a32cea9cf6d3a76581fdfd3c12e4c8 (diff)
Discovery: Speed up initial run. #2796
Diffstat (limited to 'csync')
-rw-r--r--csync/src/csync.c10
-rw-r--r--csync/src/csync.h5
-rw-r--r--csync/src/csync_private.h12
-rw-r--r--csync/src/csync_statedb.c8
-rw-r--r--csync/src/csync_update.c2
5 files changed, 18 insertions, 19 deletions
diff --git a/csync/src/csync.c b/csync/src/csync.c
index 2390eaae8..65a0655af 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 85a4bfb96..f227c7875 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 7a4e2a5eb..8552bf38c 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 1f82e8c3e..1ba406f34 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 fdb6df911..1c89a87ec 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