static void process_commit_list (CcnetProcessor *processor, char *content, int clen) { USE_PRIV; char *object_id; int n_objects; int i; if (clen % 41 != 1 || content[clen-1] != '\0') { g_warning ("[getcommit] Bad commit id list.\n"); ccnet_processor_send_update (processor, SC_BAD_OL, SS_BAD_OL, NULL, 0); transfer_task_set_error (((SeafileGetcommitProc *)processor)->tx_task, TASK_ERR_DOWNLOAD_COMMIT); ccnet_processor_done (processor, FALSE); return; } n_objects = clen/41; request_object_batch_begin(priv); object_id = content; for (i = 0; i < n_objects; ++i) { object_id[40] = '\0'; check_commit (processor, object_id); object_id += 41; } request_object_batch_flush (processor, priv); if (priv->pending_objects == 0) { ccnet_processor_send_update (processor, SC_END, SS_END, NULL, 0); ccnet_processor_done (processor, TRUE); } }
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 process_fsroot_list (CcnetProcessor *processor) { GList *ptr; char *object_id; USE_PRIV; /* When there are more than one fs roots, there may be many * duplicate fs objects between different commits. * We remember checked fs objects in a hash table to avoid * redundant checks. */ if (priv->n_roots > 1) priv->fs_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); request_object_batch_begin (priv); for (ptr = priv->fs_roots; ptr != NULL; ptr = ptr->next) { object_id = ptr->data; /* Empty dir or file always exists. */ if (strcmp (object_id, EMPTY_SHA1) == 0) { object_id += 41; continue; } #ifdef DEBUG seaf_debug ("[recvfs] Inspect object %s.\n", object_id); #endif g_queue_push_tail (priv->dir_queue, g_strdup(object_id)); g_free (object_id); } g_list_free (priv->fs_roots); priv->fs_roots = NULL; }
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); }