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 recv_fs_object (CcnetProcessor *processor, char *content, int clen) { USE_PRIV; ObjectPack *pack = (ObjectPack *)content; uint32_t type; if (clen < sizeof(ObjectPack)) { g_warning ("invalid object id.\n"); goto bad; } seaf_debug ("[recvfs] Recv fs object %.8s.\n", pack->id); --priv->pending_objects; type = seaf_metadata_type_from_data(pack->object, clen); if (type == SEAF_METADATA_TYPE_DIR) { SeafDir *dir; dir = seaf_dir_from_data (pack->id, pack->object, clen - 41); if (!dir) { g_warning ("Bad directory object %s.\n", pack->id); goto bad; } int ret = check_seafdir (processor, dir); seaf_dir_free (dir); if (ret < 0) goto bad; } else if (type == SEAF_METADATA_TYPE_FILE) { /* TODO: check seafile format. */ #if 0 int ret = seafile_check_data_format (pack->object, clen - 41); if (ret < 0) { goto bad; } #endif } else { g_warning ("Invalid object type.\n"); goto bad; } if (save_fs_object (processor, pack, clen) < 0) { goto bad; } return 0; bad: ccnet_processor_send_response (processor, SC_BAD_OBJECT, SS_BAD_OBJECT, NULL, 0); g_warning ("[recvfs] Bad fs object received.\n"); ccnet_processor_done (processor, FALSE); return -1; }
static int recv_fs_object (CcnetProcessor *processor, char *content, int clen) { USE_PRIV; ObjectPack *pack = (ObjectPack *)content; uint32_t type; /* TransferTask *task = ((SeafileGetfsProc *)processor)->tx_task; */ if (clen < sizeof(ObjectPack)) { g_warning ("[getfs] invalid object id.\n"); goto bad; } --priv->pending_objects; type = seaf_metadata_type_from_data(pack->object, clen); if (type == SEAF_METADATA_TYPE_DIR) { SeafDir *dir; dir = seaf_dir_from_data (pack->id, pack->object, clen - 41); if (!dir) { g_warning ("[getfs] Bad directory object %s.\n", pack->id); goto bad; } g_queue_push_tail (priv->inspect_queue, g_strdup(dir->dir_id)); seaf_dir_free (dir); } else if (type == SEAF_METADATA_TYPE_FILE) { /* TODO: check seafile format. */ #if 0 int ret = seafile_check_data_format (pack->object, clen - 41); if (ret < 0) { goto bad; } #endif } else { g_warning ("[getfs] Invalid object type.\n"); goto bad; } if (save_fs_object (pack, clen) < 0) { goto bad; } g_hash_table_remove (priv->fs_objects, pack->id); return 0; bad: g_warning ("Bad fs object received.\n"); transfer_task_set_error (((SeafileGetfsProc *)processor)->tx_task, TASK_ERR_DOWNLOAD_FS); ccnet_processor_send_update (processor, SC_BAD_OBJECT, SS_BAD_OBJECT, NULL, 0); ccnet_processor_done (processor, FALSE); return -1; }