gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3241 - in GNUnet: . src/applications/fs/tools


From: grothoff
Subject: [GNUnet-SVN] r3241 - in GNUnet: . src/applications/fs/tools
Date: Thu, 17 Aug 2006 18:08:03 -0700 (PDT)

Author: grothoff
Date: 2006-08-17 18:07:58 -0700 (Thu, 17 Aug 2006)
New Revision: 3241

Modified:
   GNUnet/src/applications/fs/tools/gnunet-download.c
   GNUnet/src/applications/fs/tools/gnunet-insert.c
   GNUnet/src/applications/fs/tools/gnunet-unindex.c
   GNUnet/todo
Log:
tools compile


Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c  2006-08-16 18:12:05 UTC 
(rev 3240)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c  2006-08-18 01:07:58 UTC 
(rev 3241)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -43,6 +43,10 @@
 
 static struct SEMAPHORE * signalFinished;
 
+static cron_t start_time;
+
+static struct FSUI_DownloadList * dl;
+
 /**
  * All gnunet-download command line options
  */
@@ -83,12 +87,12 @@
             event->data.DownloadProgress.completed,
             event->data.DownloadProgress.total,
             (event->data.DownloadProgress.completed/1024.0) /
-            (((double)(get_time()-(event->data.DownloadProgress.start_time - 
1)))
+            (((double)(get_time()-(start_time - 1)))
              / (double)cronSECONDS) );
     }
     break;
   case FSUI_download_aborted:
-    if (FSUI_getDownloadParent(event->data.DownloadError.pos) == NULL) {
+    if (dl == event->data.DownloadError.dc.pos) {
       /* top-download aborted */
       PRINTF(_("Error downloading: %s\n"),
             event->data.DownloadError.message);
@@ -113,10 +117,9 @@
               "Speed was %8.3f KiB per second.\n"),
             event->data.DownloadProgress.filename,
             (event->data.DownloadProgress.completed/1024.0) /
-            (((double)(get_time()-(event->data.DownloadProgress.start_time - 
1)))
+            (((double)(get_time()-(start_time - 1)))
              / (double)cronSECONDS) );
-      if (ECRS_equalsUri(event->data.DownloadProgress.main_uri,
-                        event->data.DownloadProgress.uri)) {
+      if (dl == event->data.DownloadProgress.dc.pos) {
        *ok = OK;
        SEMAPHORE_UP(signalFinished);
       }
@@ -143,7 +146,6 @@
   struct FSUI_Context * ctx;
   struct ECRS_URI * uri;
   int i;
-  struct FSUI_DownloadList * dl;
 
   /* startup */
   ectx = GE_create_context_stderr(NO, 
@@ -218,7 +220,7 @@
                   NO,
                   &progressModel,
                   &ok);
-
+  start_time = get_time();
   dl = FSUI_startDownload(ctx,
                          anonymity,
                          do_recursive,

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-08-16 18:12:05 UTC 
(rev 3240)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-08-18 01:07:58 UTC 
(rev 3241)
@@ -50,6 +50,13 @@
 
 static struct FSUI_Context * ctx;
 
+/**
+ * The main upload
+ */
+static struct FSUI_UploadList * ul;
+
+static cron_t start_time;
+
 /* ************ config options ******** */
 
 static struct ECRS_MetaData * meta;
@@ -86,6 +93,8 @@
 
 static int extract_only;
 
+static int do_disable_creation_time;
+
 static void convertId(const char * s,
                      HashCode512 * id) {
   if ( (s != NULL) &&
@@ -153,61 +162,50 @@
     if (*verboselevel) {
       char * ret;
 
-      delta = event->data.UploadProgress.main_eta - get_time();
+      delta = event->data.UploadProgress.eta - get_time();
       ret = string_get_fancy_time_interval(delta);
       PRINTF(_("%16llu of %16llu bytes inserted "
-              "(estimating %s to completion)\n"),
-            event->data.UploadProgress.main_completed,
-            event->data.UploadProgress.main_total,
-            ret);
+              "(estimating %6s to completion) - %s\n"),
+            event->data.UploadProgress.completed,
+            event->data.UploadProgress.total,
+            ret,
+            event->data.UploadProgress.filename);
       FREE(ret);
     }
     break;
   case FSUI_upload_complete:
     if (*verboselevel) {
-      if (0 == strcmp(event->data.UploadComplete.filename,
-                     event->data.UploadComplete.main_filename)) {
-       delta = event->data.UploadComplete.eta
-         - event->data.UploadComplete.start_time;
-       PRINTF(_("Upload of `%s' complete, "
-                "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
-              event->data.UploadComplete.filename,
-              event->data.UploadComplete.total,
-              delta / cronSECONDS,
-              (delta == 0)
-              ? (double) (-1.0)
-              : (double) (event->data.UploadComplete.total
-                          / 1024.0 * cronSECONDS / delta));
-      } else {
-       cron_t now;
-
-       now = get_time();
-       delta = now - event->data.UploadComplete.start_time;
-       PRINTF(_("Upload of `%s' complete, "
-                "current average speed is %8.3f KiB/s.\n"),
-              event->data.UploadComplete.filename,
-              (delta == 0)
-              ? (double) (-1.0)
-              : (double) (event->data.UploadComplete.completed
-                          / 1024.0 * cronSECONDS / delta));    
-      }
+      delta = get_time() - start_time;
+      PRINTF(_("Upload of `%s' complete, "
+              "%llu bytes took %llu seconds (%8.3f KiB/s).\n"),
+            event->data.UploadComplete.filename,
+            event->data.UploadComplete.total,
+            delta / cronSECONDS,
+            (delta == 0)
+            ? (double) (-1.0)
+            : (double) (event->data.UploadComplete.total
+                        / 1024.0 * cronSECONDS / delta));
     }
     fstring = ECRS_uriToString(event->data.UploadComplete.uri);        
     printf(_("File `%s' has URI: %s\n"),
           event->data.UploadComplete.filename,
           fstring);
     FREE(fstring);
-    if (0 == strcmp(event->data.UploadComplete.main_filename,
-                   event->data.UploadComplete.filename)) {
+    if (ul == event->data.UploadComplete.uc.pos) {
       postProcess(event->data.UploadComplete.uri);
       if (exitSignal != NULL)
        SEMAPHORE_UP(exitSignal);
     }
-
     break;
+  case FSUI_upload_aborted:
+    printf(_("\nUpload aborted.\n"));
+    errorCode = 1;
+    if (exitSignal != NULL)
+      SEMAPHORE_UP(exitSignal); /* always exit main? */
+    break;
   case FSUI_upload_error:
     printf(_("\nError uploading file: %s\n"),
-          event->data.message);
+          event->data.UploadError.message);
     errorCode = 1;
     if (exitSignal != NULL)
       SEMAPHORE_UP(exitSignal); /* always exit main? */
@@ -231,6 +229,9 @@
     gettext_noop("even if gnunetd is running on the local machine, force the"
                 " creation of a copy instead of making a link to the GNUnet 
share directory"),
     0, &gnunet_getopt_configure_set_one, &do_copy }, 
+  { 'd', "disable-creation-time", NULL,
+    gettext_noop("disable adding the creation time to the metadata of the 
uploaded file"),
+    0, &gnunet_getopt_configure_set_one, &do_disable_creation_time }, 
   { 'D', "direct", NULL,
     gettext_noop("use libextractor to add additional direct references to 
directory entries"),
     0, &gnunet_getopt_configure_set_one, &do_direct_references }, 
@@ -299,7 +300,6 @@
 int main(int argc, 
         const char ** argv) {
   const char * filename;
-  struct FSUI_UploadList * ul;
   int i;
   char * tmp;
   unsigned long long verbose;
@@ -403,21 +403,32 @@
       }
     }
   } else { /* ordinary insertion checks */
-    if (NULL != next_id)
-      errexit(_("Option `%s' makes no sense without option `%s'.\n"),
+    if (NULL != next_id) {
+      fprintf(stderr,
+             _("Option `%s' makes no sense without option `%s'.\n"),
              "-N", "-P");
-    if (NULL != prev_id)
-      errexit(_("Option `%s' makes no sense without option `%s'.\n"),
+      return -1;
+    }
+    if (NULL != prev_id) {
+      fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
              "-u", "-P");
-    if (NULL != this_id)
-      errexit(_("Option `%s' makes no sense without option `%s'.\n"),
+      return -1;
+    }
+    if (NULL != this_id) {
+      fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
              "-t", "-P");
-    if (0 != interval)
-      errexit(_("Option `%s' makes no sense without option `%s'.\n"),
+      return -1;
+    }
+    if (0 != interval) {
+      fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
              "-i", "-P");
-    if (is_sporadic)
-      errexit(_("Option `%s' makes no sense without option `%s'.\n"),
+      return -1;
+    }
+    if (is_sporadic) {
+      fprintf(stderr, _("Option `%s' makes no sense without option `%s'.\n"),
              "-S", "-P");
+      return -1;
+    }
   }
 
   exitSignal = SEMAPHORE_CREATE(0);
@@ -432,10 +443,9 @@
 
   /* first insert all of the top-level files or directories */
   tmp = string_expandFileName(ectx, filename);
-  if (! testConfigurationString("FS",
-                               "DISABLE-CREATION-TIME",
-                               "YES"))
+  if (! do_disable_creation_time)
     ECRS_addPublicationDateToMetaData(meta);
+  start_time = get_time();
   ul = FSUI_startUpload(ctx,
                        tmp,
                        anonymity,

Modified: GNUnet/src/applications/fs/tools/gnunet-unindex.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-unindex.c   2006-08-16 18:12:05 UTC 
(rev 3240)
+++ GNUnet/src/applications/fs/tools/gnunet-unindex.c   2006-08-18 01:07:58 UTC 
(rev 3241)
@@ -40,6 +40,8 @@
 
 static struct SEMAPHORE * exitSignal;
 
+static cron_t start_time;
+
 static int errorCode;
 
 /**
@@ -63,7 +65,7 @@
     break;
   case FSUI_unindex_complete:
     if (*verboselevel) {
-      delta = get_time() - event->data.UnindexComplete.start_time;
+      delta = get_time() - start_time;
       PRINTF(
       _("\nUnindexing of `%s' complete, %llu bytes took %llu seconds (%8.3f 
KiB/s).\n"),
       event->data.UnindexComplete.filename,
@@ -77,7 +79,7 @@
     break;
   case FSUI_unindex_error:
     printf(_("\nError unindexing file: %s\n"),
-          event->data.message);
+          event->data.UnindexError.message);
     errorCode = 1;
     SEMAPHORE_UP(exitSignal); /* always exit main? */
     break;
@@ -160,6 +162,7 @@
                   NO,
                   &printstatus,
                   &verbose);
+  start_time = get_time();
   filename = string_expandFileName(ectx,
                                   argv[i]);
   ul = FSUI_unindex(ctx,

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-16 18:12:05 UTC (rev 3240)
+++ GNUnet/todo 2006-08-18 01:07:58 UTC (rev 3241)
@@ -28,11 +28,10 @@
       stats, topology_default, state, getoption, advertising,
       traffic, ecrs_core, template, tbench, tracekit, fs/fslib,
       fs/module, gap, fs/ecrs, fs/uritrack, fs/namespace,
-      fs/fsui, fs/collection compile
-    + fs/fsui, fs/collection, fs/uritrack, fs/namespace 
+      fs/fsui, fs/collection, fs/tools compile
+    + fs/fsui, fs/collection, fs/uritrack, fs/namespace
       must still be revised to match new API!
     + bootstrap_http: maybe switch to libwww?
-    + for fs: fs/tools (2500)
     + rest: sqstore_mysql, dht, rpc, topology_f2f, vpn
     + low priority: chat, kvstore_sqlite, testbed
   * setup:





reply via email to

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