aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-download.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-download.c')
-rw-r--r--src/fs/gnunet-download.c94
1 files changed, 32 insertions, 62 deletions
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 63895d4b2..6f50922be 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -24,9 +24,6 @@
24 * @author Krista Bennett 24 * @author Krista Bennett
25 * @author James Blackwell 25 * @author James Blackwell
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - download-directory option support (do_directory)
30 */ 27 */
31#include "platform.h" 28#include "platform.h"
32#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
@@ -51,8 +48,6 @@ static unsigned int parallelism = 16;
51 48
52static int do_recursive; 49static int do_recursive;
53 50
54static int do_directory;
55
56static char *filename; 51static char *filename;
57 52
58 53
@@ -133,15 +128,8 @@ progress_cb (void *cls,
133 info->value.download.filename, 128 info->value.download.filename,
134 s); 129 s);
135 GNUNET_free (s); 130 GNUNET_free (s);
136 if (do_directory) 131 if (info->value.download.dc == dc)
137 { 132 GNUNET_SCHEDULER_shutdown (sched);
138 GNUNET_break (0); //FIXME: not implemented
139 }
140 else
141 {
142 if (info->value.download.dc == dc)
143 GNUNET_SCHEDULER_shutdown (sched);
144 }
145 break; 133 break;
146 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 134 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
147 if (info->value.download.dc == dc) 135 if (info->value.download.dc == dc)
@@ -181,31 +169,24 @@ run (void *cls,
181 enum GNUNET_FS_DownloadOptions options; 169 enum GNUNET_FS_DownloadOptions options;
182 170
183 sched = s; 171 sched = s;
184 if (do_directory) 172 uri = GNUNET_FS_uri_parse (args[0],
173 &emsg);
174 if (NULL == uri)
185 { 175 {
186 GNUNET_break (0); //FIXME: not implemented 176 fprintf (stderr,
177 _("Failed to parse URI: %s\n"),
178 emsg);
179 GNUNET_free (emsg);
180 ret = 1;
181 return;
187 } 182 }
188 else 183 if (! GNUNET_FS_uri_test_chk (uri))
189 { 184 {
190 uri = GNUNET_FS_uri_parse (args[0], 185 fprintf (stderr,
191 &emsg); 186 "Only CHK URIs supported right now.\n");
192 if (NULL == uri) 187 ret = 1;
193 { 188 GNUNET_FS_uri_destroy (uri);
194 fprintf (stderr, 189 return;
195 _("Failed to parse URI: %s\n"),
196 emsg);
197 GNUNET_free (emsg);
198 ret = 1;
199 return;
200 }
201 if (! GNUNET_FS_uri_test_chk (uri))
202 {
203 fprintf (stderr,
204 "Only CHK URIs supported right now.\n");
205 ret = 1;
206 GNUNET_FS_uri_destroy (uri);
207 return;
208 }
209 } 190 }
210 if (NULL == filename) 191 if (NULL == filename)
211 { 192 {
@@ -237,29 +218,22 @@ run (void *cls,
237 options = GNUNET_FS_DOWNLOAD_OPTION_NONE; 218 options = GNUNET_FS_DOWNLOAD_OPTION_NONE;
238 if (do_recursive) 219 if (do_recursive)
239 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; 220 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
240 if (do_directory) 221 dc = GNUNET_FS_download_start (ctx,
222 uri,
223 NULL,
224 filename,
225 0,
226 GNUNET_FS_uri_chk_get_file_size (uri),
227 anonymity,
228 options,
229 NULL,
230 NULL);
231 GNUNET_FS_uri_destroy (uri);
232 if (dc == NULL)
241 { 233 {
242 GNUNET_break (0); //FIXME: not implemented 234 GNUNET_FS_stop (ctx);
243 } 235 ctx = NULL;
244 else 236 return;
245 {
246 dc = GNUNET_FS_download_start (ctx,
247 uri,
248 NULL,
249 filename,
250 0,
251 GNUNET_FS_uri_chk_get_file_size (uri),
252 anonymity,
253 options,
254 NULL,
255 NULL);
256 GNUNET_FS_uri_destroy (uri);
257 if (dc == NULL)
258 {
259 GNUNET_FS_stop (ctx);
260 ctx = NULL;
261 return;
262 }
263 } 237 }
264 GNUNET_SCHEDULER_add_delayed (sched, 238 GNUNET_SCHEDULER_add_delayed (sched,
265 GNUNET_TIME_UNIT_FOREVER_REL, 239 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -275,10 +249,6 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
275 {'a', "anonymity", "LEVEL", 249 {'a', "anonymity", "LEVEL",
276 gettext_noop ("set the desired LEVEL of receiver-anonymity"), 250 gettext_noop ("set the desired LEVEL of receiver-anonymity"),
277 1, &GNUNET_GETOPT_set_uint, &anonymity}, 251 1, &GNUNET_GETOPT_set_uint, &anonymity},
278 {'d', "directory", NULL,
279 gettext_noop
280 ("download a GNUnet directory that has already been downloaded. Requires that a filename of an existing file is specified instead of the URI. The download will only download the top-level files in the directory unless the `-R' option is also specified."),
281 0, &GNUNET_GETOPT_set_one, &do_directory},
282 {'D', "delete-incomplete", NULL, 252 {'D', "delete-incomplete", NULL,
283 gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), 253 gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
284 0, &GNUNET_GETOPT_set_one, &delete_incomplete}, 254 0, &GNUNET_GETOPT_set_one, &delete_incomplete},