aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/fs.c')
-rw-r--r--src/fs/fs.c106
1 files changed, 75 insertions, 31 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c
index df0bf881a..417461404 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -1191,6 +1191,21 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc)
1191 1191
1192 1192
1193/** 1193/**
1194 * Synchronize this unindex struct with its mirror
1195 * on disk. Note that all internal FS-operations that change
1196 * publishing structs should already call "sync" internally,
1197 * so this function is likely not useful for clients.
1198 *
1199 * @param uc the struct to sync
1200 */
1201void
1202GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc)
1203{
1204 /* FIXME */
1205}
1206
1207
1208/**
1194 * Deserialize information about pending publish operations. 1209 * Deserialize information about pending publish operations.
1195 * 1210 *
1196 * @param h master context 1211 * @param h master context
@@ -1225,7 +1240,9 @@ deserialize_unindex_file (void *cls,
1225 struct GNUNET_FS_Handle *h = cls; 1240 struct GNUNET_FS_Handle *h = cls;
1226 struct GNUNET_BIO_ReadHandle *rh; 1241 struct GNUNET_BIO_ReadHandle *rh;
1227 struct GNUNET_FS_UnindexContext *uc; 1242 struct GNUNET_FS_UnindexContext *uc;
1243 struct GNUNET_FS_ProgressInfo pi;
1228 char *emsg; 1244 char *emsg;
1245 uint32_t state;
1229 1246
1230 uc = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); 1247 uc = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext));
1231 uc->h = h; 1248 uc->h = h;
@@ -1233,33 +1250,70 @@ deserialize_unindex_file (void *cls,
1233 rh = GNUNET_BIO_read_open (filename); 1250 rh = GNUNET_BIO_read_open (filename);
1234 if (rh == NULL) 1251 if (rh == NULL)
1235 goto cleanup; 1252 goto cleanup;
1236 /* FIXME: do unindex state here! */
1237#if 0
1238 if ( (GNUNET_OK != 1253 if ( (GNUNET_OK !=
1239 GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) || 1254 GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10*1024)) ||
1240 (GNUNET_OK != 1255 (GNUNET_OK !=
1241 GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) || 1256 GNUNET_BIO_read_int64 (rh, &uc->file_size)) ||
1242 (GNUNET_OK != 1257 (GNUNET_OK !=
1243 GNUNET_BIO_read_int32 (rh, &options)) || 1258 GNUNET_BIO_read_int64 (rh, &uc->start_time.value)) ||
1244 (GNUNET_OK !=
1245 GNUNET_BIO_read_int32 (rh, &all_done)) ||
1246 (GNUNET_OK !=
1247 GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) ||
1248 (GNUNET_OK !=
1249 GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) ||
1250 (GNUNET_OK != 1259 (GNUNET_OK !=
1251 GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024)) ) 1260 GNUNET_BIO_read_int32 (rh, &state)) )
1252 goto cleanup; 1261 goto cleanup;
1253 pc->options = options; 1262 uc->state = (enum UnindexState) state;
1254 pc->all_done = all_done; 1263 switch (state)
1255 pc->fi = deserialize_file_information (h, fi_root); 1264 {
1256 if (pc->fi == NULL) 1265 case UNINDEX_STATE_HASHING:
1257 goto cleanup; 1266 break;
1258#endif 1267 case UNINDEX_STATE_FS_NOTIFY:
1259 /* FIXME: generate RESUME event */ 1268 if (GNUNET_OK !=
1260 /* FIXME: re-start unindexing (if needed)... */ 1269 GNUNET_BIO_read (rh, "unindex-hash", &uc->file_id, sizeof (GNUNET_HashCode)))
1270 goto cleanup;
1271 break;
1272 case UNINDEX_STATE_DS_REMOVE:
1273 break;
1274 case UNINDEX_STATE_COMPLETE:
1275 break;
1276 case UNINDEX_STATE_ERROR:
1277 if (GNUNET_OK !=
1278 GNUNET_BIO_read_string (rh, "unindex-emsg", &uc->emsg, 10*1024))
1279 goto cleanup;
1280 break;
1281 case UNINDEX_STATE_ABORTED:
1282 GNUNET_break (0);
1283 goto cleanup;
1284 default:
1285 GNUNET_break (0);
1286 goto cleanup;
1287 }
1288 pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME;
1289 pi.value.unindex.specifics.resume.message = uc->emsg;
1290 GNUNET_FS_unindex_make_status_ (&pi,
1291 uc,
1292 (uc->state == UNINDEX_STATE_COMPLETE)
1293 ? uc->file_size
1294 : 0);
1261 switch (uc->state) 1295 switch (uc->state)
1262 { 1296 {
1297 case UNINDEX_STATE_HASHING:
1298 GNUNET_CRYPTO_hash_file (uc->h->sched,
1299 GNUNET_SCHEDULER_PRIORITY_IDLE,
1300 uc->filename,
1301 HASHING_BLOCKSIZE,
1302 &GNUNET_FS_unindex_process_hash_,
1303 uc);
1304 break;
1305 case UNINDEX_STATE_FS_NOTIFY:
1306 uc->state = UNINDEX_STATE_HASHING;
1307 GNUNET_FS_unindex_process_hash_ (uc,
1308 &uc->file_id);
1309 break;
1310 case UNINDEX_STATE_DS_REMOVE:
1311 GNUNET_FS_unindex_do_remove_ (uc);
1312 break;
1313 case UNINDEX_STATE_COMPLETE:
1314 case UNINDEX_STATE_ERROR:
1315 /* no need to resume any operation, we were done */
1316 break;
1263 default: 1317 default:
1264 break; 1318 break;
1265 } 1319 }
@@ -1271,18 +1325,10 @@ deserialize_unindex_file (void *cls,
1271 filename, 1325 filename,
1272 emsg); 1326 emsg);
1273 GNUNET_free (emsg); 1327 GNUNET_free (emsg);
1274 rh = NULL;
1275 goto cleanup;
1276 } 1328 }
1277 return GNUNET_OK; 1329 return GNUNET_OK;
1278 cleanup: 1330 cleanup:
1279 /* FIXME: clean unindex state here! */ 1331 GNUNET_free_non_null (uc->filename);
1280#if 0
1281 GNUNET_free_non_null (pc->nid);
1282 GNUNET_free_non_null (pc->nuid);
1283 GNUNET_free_non_null (fi_root);
1284 GNUNET_free_non_null (ns);
1285#endif
1286 if ( (rh != NULL) && 1332 if ( (rh != NULL) &&
1287 (GNUNET_OK != 1333 (GNUNET_OK !=
1288 GNUNET_BIO_read_close (rh, &emsg)) ) 1334 GNUNET_BIO_read_close (rh, &emsg)) )
@@ -1301,8 +1347,6 @@ deserialize_unindex_file (void *cls,
1301} 1347}
1302 1348
1303 1349
1304
1305
1306/** 1350/**
1307 * Deserialize information about pending publish operations. 1351 * Deserialize information about pending publish operations.
1308 * 1352 *