static void on_seafdir_read (OSAsyncResult *res, void *cb_data) { CcnetProcessor *processor = cb_data; SeafDir *dir; USE_PRIV; --(priv->inspect_objects); --(priv->checking_dirs); if (!res->success) { request_object_batch (processor, priv, res->obj_id); return; } #ifdef DEBUG seaf_debug ("[recvfs] Read seafdir %s.\n", res->obj_id); #endif dir = seaf_dir_from_data (res->obj_id, res->data, res->len, (priv->repo_version > 0)); if (!dir) { seaf_warning ("[recvfs] Corrupt dir object %s.\n", res->obj_id); request_object_batch (processor, priv, res->obj_id); return; } int ret = check_seafdir (processor, dir); seaf_dir_free (dir); if (ret < 0) return; }
static int check_object (CcnetProcessor *processor) { USE_PRIV; char *obj_id; SeafDir *dir; static int i = 0; request_object_batch_begin(priv); /* process inspect queue */ /* Note: All files in a directory must be checked in an iteration, * so we may send out more items than REQUEST_THRESHOLD */ while (g_hash_table_size (priv->fs_objects) < MAX_NUM_UNREVD) { obj_id = (char *) g_queue_pop_head (priv->inspect_queue); if (obj_id == NULL) break; if (!seaf_fs_manager_object_exists(seaf->fs_mgr, obj_id)) { request_object_batch (processor, priv, obj_id); } else { dir = seaf_fs_manager_get_seafdir (seaf->fs_mgr, obj_id); if (!dir) { /* corrupt dir object */ request_object_batch (processor, priv, obj_id); } else { check_seafdir(processor, dir); seaf_dir_free (dir); } } g_free (obj_id); /* free the memory */ } request_object_batch_flush (processor, priv); /* check end condition */ if (i%10 == 0) seaf_debug ("[getfs] pending objects num: %d\n", priv->pending_objects); ++i; if (priv->pending_objects == 0 && g_queue_is_empty(priv->inspect_queue)) { ccnet_processor_send_update (processor, SC_END, SS_END, NULL, 0); ccnet_processor_done (processor, TRUE); return FALSE; } else return TRUE; }
static void check_commit (CcnetProcessor *processor, const char *commit_id) { USE_PRIV; if (!seaf_commit_manager_commit_exists (seaf->commit_mgr, commit_id)) { request_object_batch (priv, commit_id); } }
static void on_seafile_stat (OSAsyncResult *res, void *cb_data) { CcnetProcessor *processor = cb_data; USE_PRIV; --(priv->inspect_objects); #ifdef DEBUG seaf_debug ("[recvfs] Stat seafile %s.\n", res->obj_id); #endif if (!res->success) request_object_batch (processor, priv, res->obj_id); }
static void check_seafdir (CcnetProcessor *processor, SeafDir *dir) { USE_PRIV; GList *ptr; SeafDirent *dent; for (ptr = dir->entries; ptr; ptr = ptr->next) { dent = ptr->data; if (!seaf_fs_manager_object_exists(seaf->fs_mgr, dent->id)) { request_object_batch (processor, priv, dent->id); continue; } if (S_ISDIR(dent->mode)) { g_queue_push_tail (priv->inspect_queue, g_strdup(dent->id)); } /* TODO: check seafile object integrity. */ } }
static void check_objects_done (void *vdata) { CcnetProcessor *processor = vdata; USE_PRIV; GList *ptr; char *obj_id; priv->worker_running = FALSE; request_object_batch_begin (priv); for (ptr = priv->fetch_objs; ptr; ptr = ptr->next) { obj_id = ptr->data; request_object_batch (processor, priv, obj_id); g_free (obj_id); } request_object_batch_flush (processor, priv); g_list_free (priv->fetch_objs); priv->fetch_objs = NULL; end_or_check_next_dir (processor, priv); }