From 88fa063a3e727580c2f66201b7a4aea720023417 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 4 May 2010 12:37:45 +0000 Subject: [PATCH] code cleanup --- TODO | 8 ++--- src/fs/fs.c | 88 ++++++++++++++--------------------------------------- 2 files changed, 26 insertions(+), 70 deletions(-) diff --git a/TODO b/TODO index 9362b0097..1f887e99a 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,13 @@ 0.9.0pre1: * FS: [CG] - code review: - => refactor fs.c to join common code segments! - => pbuf sprintf'ing - => initial master directory scanning - => document directory structure (and use #define's for the directory names!) + => address pbuf sprintf'ing - SKS update searches should be attached to individual search results, not to the entire SKS search (!) => API change (event signalling) & serialization change (!) + => update search results should be stored in different result directory due + to possibility of naming conflicts! + => outch: ditto for recursive downloads (!) - persistence testing (publish, unindex, search, download): => need driver! => schedule suspending tasks DURING event handler => good coverage! diff --git a/src/fs/fs.c b/src/fs/fs.c index 749db4dfe..a514c32c7 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -1656,24 +1656,6 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) } -/** - * Deserialize information about pending publish operations. - * - * @param h master context - */ -static void -deserialize_publish (struct GNUNET_FS_Handle *h) -{ - char *dn; - - dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, ""); - if (dn == NULL) - return; - GNUNET_DISK_directory_scan (dn, &deserialize_publish_file, h); - GNUNET_free (dn); -} - - /** * Function called with a filename of serialized unindexing operation * to deserialize. @@ -1796,24 +1778,6 @@ deserialize_unindex_file (void *cls, } -/** - * Deserialize information about pending publish operations. - * - * @param h master context - */ -static void -deserialize_unindex (struct GNUNET_FS_Handle *h) -{ - char *dn; - - dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, ""); - if (dn == NULL) - return; - GNUNET_DISK_directory_scan (dn, &deserialize_unindex_file, h); - GNUNET_free (dn); -} - - /** * Deserialize a download. * @@ -2442,24 +2406,6 @@ deserialize_search_file (void *cls, } -/** - * Deserialize information about pending search operations. - * - * @param h master context - */ -static void -deserialize_search_master (struct GNUNET_FS_Handle *h) -{ - char *dn; - - dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_SEARCH, ""); - if (dn == NULL) - return; - GNUNET_DISK_directory_scan (dn, &deserialize_search_file, h); - GNUNET_free (dn); -} - - /** * Function called with a filename of serialized download operation * to deserialize. @@ -2507,20 +2453,24 @@ deserialize_download_file (void *cls, /** - * Deserialize information about pending download operations. + * Deserialize informatin about pending operations. * - * @param h master context + * @param master_path which master directory should be scanned + * @param proc function to call for each entry (will get 'h' for 'cls') + * @param h the 'struct GNUNET_FS_Handle*' */ static void -deserialize_download_master (struct GNUNET_FS_Handle *h) +deserialization_master (const char *master_path, + GNUNET_FileNameCallback proc, + struct GNUNET_FS_Handle *h) { char *dn; - dn = get_serialization_file_name (h, GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, ""); + dn = get_serialization_file_name (h, master_path, ""); if (dn == NULL) return; - GNUNET_DISK_directory_scan (dn, &deserialize_download_file, h); - GNUNET_free (dn); + GNUNET_DISK_directory_scan (dn, proc, h); + GNUNET_free (dn); } @@ -2581,12 +2531,18 @@ GNUNET_FS_start (struct GNUNET_SCHEDULER_Handle *sched, va_end (ap); if (0 != (GNUNET_FS_FLAGS_PERSISTENCE & flags)) { - /* FIXME: could write one generic deserialization - function instead of these four... */ - deserialize_publish (ret); - deserialize_search_master (ret); - deserialize_download_master (ret); - deserialize_unindex (ret); + deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, + &deserialize_publish_file, + ret); + deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_SEARCH, + &deserialize_search_file, + ret); + deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, + &deserialize_download_file, + ret); + deserialization_master (GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, + &deserialize_unindex_file, + ret); } return ret; } -- 2.25.1