code cleanup
authorChristian Grothoff <christian@grothoff.org>
Tue, 4 May 2010 12:37:45 +0000 (12:37 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 4 May 2010 12:37:45 +0000 (12:37 +0000)
TODO
src/fs/fs.c

diff --git a/TODO b/TODO
index 9362b00978736dfd23ecf0c031909c2107393f17..1f887e99abd37413a649c01de7a3927b3247db44 100644 (file)
--- 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!
index 749db4dfea19bcbe3496ac29ace1f73bc7ef15a0..a514c32c7c8c7ffb5d539518ec10b420a720b67e 100644 (file)
@@ -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;
 }