gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11178 - in gnunet: . src/fs


From: gnunet
Subject: [GNUnet-SVN] r11178 - in gnunet: . src/fs
Date: Tue, 4 May 2010 14:37:45 +0200

Author: grothoff
Date: 2010-05-04 14:37:45 +0200 (Tue, 04 May 2010)
New Revision: 11178

Modified:
   gnunet/TODO
   gnunet/src/fs/fs.c
Log:
code cleanup

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-05-04 12:36:12 UTC (rev 11177)
+++ gnunet/TODO 2010-05-04 12:37:45 UTC (rev 11178)
@@ -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!

Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c  2010-05-04 12:36:12 UTC (rev 11177)
+++ gnunet/src/fs/fs.c  2010-05-04 12:37:45 UTC (rev 11178)
@@ -1657,24 +1657,6 @@
 
 
 /**
- * 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.
  *
@@ -1797,24 +1779,6 @@
 
 
 /**
- * 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.
  *
  * @param h overall context
@@ -2443,24 +2407,6 @@
 
 
 /**
- * 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 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 @@
   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;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]