aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_download.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/fs/fs_download.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r--src/fs/fs_download.c370
1 files changed, 169 insertions, 201 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 6b72b4e56..a3c5b9b62 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -111,19 +111,19 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
111{ 111{
112 pi->value.download.dc = dc; 112 pi->value.download.dc = dc;
113 pi->value.download.cctx = dc->client_info; 113 pi->value.download.cctx = dc->client_info;
114 pi->value.download.pctx 114 pi->value.download.pctx =
115 = (dc->parent == NULL) ? NULL : dc->parent->client_info; 115 (dc->parent == NULL) ? NULL : dc->parent->client_info;
116 pi->value.download.sctx 116 pi->value.download.sctx =
117 = (dc->search == NULL) ? NULL : dc->search->client_info; 117 (dc->search == NULL) ? NULL : dc->search->client_info;
118 pi->value.download.uri = dc->uri; 118 pi->value.download.uri = dc->uri;
119 pi->value.download.filename = dc->filename; 119 pi->value.download.filename = dc->filename;
120 pi->value.download.size = dc->length; 120 pi->value.download.size = dc->length;
121 pi->value.download.duration 121 pi->value.download.duration =
122 = GNUNET_TIME_absolute_get_duration (dc->start_time); 122 GNUNET_TIME_absolute_get_duration (dc->start_time);
123 pi->value.download.completed = dc->completed; 123 pi->value.download.completed = dc->completed;
124 pi->value.download.anonymity = dc->anonymity; 124 pi->value.download.anonymity = dc->anonymity;
125 pi->value.download.eta 125 pi->value.download.eta =
126 = GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length); 126 GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length);
127 pi->value.download.is_active = (dc->client == NULL) ? GNUNET_NO : GNUNET_YES; 127 pi->value.download.is_active = (dc->client == NULL) ? GNUNET_NO : GNUNET_YES;
128 if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE)) 128 if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE))
129 dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi); 129 dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi);
@@ -194,9 +194,8 @@ struct ProcessResultClosure
194 * @param value value in the hash map (a 'struct DownloadRequest') 194 * @param value value in the hash map (a 'struct DownloadRequest')
195 * @return GNUNET_YES (we should continue to iterate); unless serious error 195 * @return GNUNET_YES (we should continue to iterate); unless serious error
196 */ 196 */
197static int 197static int process_result_with_request (void *cls, const GNUNET_HashCode * key,
198process_result_with_request (void *cls, 198 void *value);
199 const GNUNET_HashCode * key, void *value);
200 199
201 200
202/** 201/**
@@ -215,8 +214,8 @@ process_result_with_request (void *cls,
215static int 214static int
216encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc, 215encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
217 const struct ContentHashKey *chk, 216 const struct ContentHashKey *chk,
218 struct DownloadRequest *dr, 217 struct DownloadRequest *dr, const char *block,
219 const char *block, size_t len, int do_store) 218 size_t len, int do_store)
220{ 219{
221 struct ProcessResultClosure prc; 220 struct ProcessResultClosure prc;
222 char enc[len]; 221 char enc[len];
@@ -245,8 +244,9 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc,
245 prc.dc = dc; 244 prc.dc = dc;
246 prc.data = enc; 245 prc.data = enc;
247 prc.size = len; 246 prc.size = len;
248 prc.type = (0 == dr->depth) 247 prc.type =
249 ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; 248 (0 ==
249 dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK;
250 prc.query = chk->query; 250 prc.query = chk->query;
251 prc.do_store = do_store; 251 prc.do_store = do_store;
252 process_result_with_request (&prc, &chk->key, dr); 252 process_result_with_request (&prc, &chk->key, dr);
@@ -275,12 +275,10 @@ static void try_reconnect (struct GNUNET_FS_DownloadContext *dc);
275 * @param length number of bytes in data 275 * @param length number of bytes in data
276 * @param data contents of the file (or NULL if they were not inlined) 276 * @param data contents of the file (or NULL if they were not inlined)
277 */ 277 */
278static void 278static void trigger_recursive_download (void *cls, const char *filename,
279trigger_recursive_download (void *cls, 279 const struct GNUNET_FS_Uri *uri,
280 const char *filename, 280 const struct GNUNET_CONTAINER_MetaData
281 const struct GNUNET_FS_Uri *uri, 281 *meta, size_t length, const void *data);
282 const struct GNUNET_CONTAINER_MetaData *meta,
283 size_t length, const void *data);
284 282
285 283
286/** 284/**
@@ -309,14 +307,14 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
309 } 307 }
310 if (dc->filename != NULL) 308 if (dc->filename != NULL)
311 { 309 {
312 h = GNUNET_DISK_file_open (dc->filename, 310 h = GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ,
313 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 311 GNUNET_DISK_PERM_NONE);
314 } 312 }
315 else 313 else
316 { 314 {
317 GNUNET_assert (dc->temp_filename != NULL); 315 GNUNET_assert (dc->temp_filename != NULL);
318 h = GNUNET_DISK_file_open (dc->temp_filename, 316 h = GNUNET_DISK_file_open (dc->temp_filename, GNUNET_DISK_OPEN_READ,
319 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 317 GNUNET_DISK_PERM_NONE);
320 } 318 }
321 if (h == NULL) 319 if (h == NULL)
322 return; /* oops */ 320 return; /* oops */
@@ -328,17 +326,16 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
328 } 326 }
329 else 327 else
330 { 328 {
331 GNUNET_FS_directory_list_contents (size, 329 GNUNET_FS_directory_list_contents (size, data, 0,
332 data, 330 &trigger_recursive_download, dc);
333 0, &trigger_recursive_download, dc);
334 GNUNET_DISK_file_unmap (m); 331 GNUNET_DISK_file_unmap (m);
335 } 332 }
336 GNUNET_DISK_file_close (h); 333 GNUNET_DISK_file_close (h);
337 if (dc->filename == NULL) 334 if (dc->filename == NULL)
338 { 335 {
339 if (0 != UNLINK (dc->temp_filename)) 336 if (0 != UNLINK (dc->temp_filename))
340 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 337 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
341 "unlink", dc->temp_filename); 338 dc->temp_filename);
342 GNUNET_free (dc->temp_filename); 339 GNUNET_free (dc->temp_filename);
343 dc->temp_filename = NULL; 340 dc->temp_filename = NULL;
344 } 341 }
@@ -483,8 +480,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
483 if (fh == NULL) 480 if (fh == NULL)
484 { 481 {
485 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn); 482 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
486 GNUNET_asprintf (&dc->emsg, 483 GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
487 _("Failed to open file `%s' for writing"), fn); 484 fn);
488 GNUNET_DISK_file_close (fh); 485 GNUNET_DISK_file_close (fh);
489 dr->state = BRS_ERROR; 486 dr->state = BRS_ERROR;
490 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; 487 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
@@ -495,8 +492,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
495 if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len)) 492 if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len))
496 { 493 {
497 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn); 494 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn);
498 GNUNET_asprintf (&dc->emsg, 495 GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"),
499 _("Failed to open file `%s' for writing"), fn); 496 fn);
500 GNUNET_DISK_file_close (fh); 497 GNUNET_DISK_file_close (fh);
501 dr->state = BRS_ERROR; 498 dr->state = BRS_ERROR;
502 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; 499 pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
@@ -516,10 +513,11 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
516 pi.value.download.specifics.progress.depth = 0; 513 pi.value.download.specifics.progress.depth = 0;
517 GNUNET_FS_download_make_status_ (&pi, dc); 514 GNUNET_FS_download_make_status_ (&pi, dc);
518 if ((NULL != dc->filename) && 515 if ((NULL != dc->filename) &&
519 (0 != truncate (dc->filename, 516 (0 !=
520 GNUNET_ntohll (dc->uri->data.chk.file_length)))) 517 truncate (dc->filename,
521 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 518 GNUNET_ntohll (dc->uri->data.chk.file_length))))
522 "truncate", dc->filename); 519 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
520 dc->filename);
523 check_completed (dc); 521 check_completed (dc);
524 break; 522 break;
525 default: 523 default:
@@ -549,10 +547,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
549 * @return 0 to continue extracting, 1 to abort 547 * @return 0 to continue extracting, 1 to abort
550 */ 548 */
551static int 549static int
552match_full_data (void *cls, 550match_full_data (void *cls, const char *plugin_name,
553 const char *plugin_name, 551 enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
554 enum EXTRACTOR_MetaType type,
555 enum EXTRACTOR_MetaFormat format,
556 const char *data_mime_type, const char *data, size_t data_len) 552 const char *data_mime_type, const char *data, size_t data_len)
557{ 553{
558 struct GNUNET_FS_DownloadContext *dc = cls; 554 struct GNUNET_FS_DownloadContext *dc = cls;
@@ -560,8 +556,8 @@ match_full_data (void *cls,
560 if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA) 556 if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
561 return 0; 557 return 0;
562#if DEBUG_DOWNLOAD 558#if DEBUG_DOWNLOAD
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u bytes of FD!\n",
564 "Found %u bytes of FD!\n", (unsigned int) data_len); 560 (unsigned int) data_len);
565#endif 561#endif
566 if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len) 562 if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len)
567 { 563 {
@@ -729,28 +725,26 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
729#if DEBUG_DOWNLOAD 725#if DEBUG_DOWNLOAD
730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Scheduling download at offset %llu and depth %u for `%s'\n", 727 "Scheduling download at offset %llu and depth %u for `%s'\n",
732 (unsigned long long) dr->offset, 728 (unsigned long long) dr->offset, dr->depth,
733 dr->depth, GNUNET_h2s (&dr->chk.query)); 729 GNUNET_h2s (&dr->chk.query));
734#endif 730#endif
735 if (GNUNET_NO != 731 if (GNUNET_NO !=
736 GNUNET_CONTAINER_multihashmap_contains_value (dc->active, 732 GNUNET_CONTAINER_multihashmap_contains_value (dc->active, &dr->chk.query,
737 &dr->chk.query, dr)) 733 dr))
738 return; /* already active */ 734 return; /* already active */
739 GNUNET_CONTAINER_multihashmap_put (dc->active, 735 GNUNET_CONTAINER_multihashmap_put (dc->active, &dr->chk.query, dr,
740 &dr->chk.query,
741 dr,
742 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 736 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
743 if (dc->client == NULL) 737 if (dc->client == NULL)
744 return; /* download not active */ 738 return; /* download not active */
745 GNUNET_CONTAINER_DLL_insert (dc->pending_head, dc->pending_tail, dr); 739 GNUNET_CONTAINER_DLL_insert (dc->pending_head, dc->pending_tail, dr);
746 dr->is_pending = GNUNET_YES; 740 dr->is_pending = GNUNET_YES;
747 if (NULL == dc->th) 741 if (NULL == dc->th)
748 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 742 dc->th =
749 sizeof (struct SearchMessage), 743 GNUNET_CLIENT_notify_transmit_ready (dc->client,
750 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 744 sizeof (struct SearchMessage),
751 GNUNET_NO, 745 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
752 &transmit_download_request, 746 GNUNET_NO,
753 dc); 747 &transmit_download_request, dc);
754} 748}
755 749
756 750
@@ -768,8 +762,7 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
768 * @param data contents of the file (or NULL if they were not inlined) 762 * @param data contents of the file (or NULL if they were not inlined)
769 */ 763 */
770static void 764static void
771trigger_recursive_download (void *cls, 765trigger_recursive_download (void *cls, const char *filename,
772 const char *filename,
773 const struct GNUNET_FS_Uri *uri, 766 const struct GNUNET_FS_Uri *uri,
774 const struct GNUNET_CONTAINER_MetaData *meta, 767 const struct GNUNET_CONTAINER_MetaData *meta,
775 size_t length, const void *data) 768 size_t length, const void *data)
@@ -790,8 +783,7 @@ trigger_recursive_download (void *cls,
790 cpos = dc->child_head; 783 cpos = dc->child_head;
791 while (cpos != NULL) 784 while (cpos != NULL)
792 { 785 {
793 if ((GNUNET_FS_uri_test_equal (uri, 786 if ((GNUNET_FS_uri_test_equal (uri, cpos->uri)) ||
794 cpos->uri)) ||
795 ((filename != NULL) && (0 == strcmp (cpos->filename, filename)))) 787 ((filename != NULL) && (0 == strcmp (cpos->filename, filename))))
796 break; 788 break;
797 cpos = cpos->next; 789 cpos = cpos->next;
@@ -812,8 +804,8 @@ trigger_recursive_download (void *cls,
812 { 804 {
813 ext = fn; 805 ext = fn;
814 us = GNUNET_FS_uri_to_string (uri); 806 us = GNUNET_FS_uri_to_string (uri);
815 GNUNET_asprintf (&fn, 807 GNUNET_asprintf (&fn, "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)],
816 "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)], ext); 808 ext);
817 GNUNET_free (ext); 809 GNUNET_free (ext);
818 GNUNET_free (us); 810 GNUNET_free (us);
819 } 811 }
@@ -858,9 +850,8 @@ trigger_recursive_download (void *cls,
858 strstr (filename + strlen (filename) - 850 strstr (filename + strlen (filename) -
859 strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT)))) 851 strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT))))
860 { 852 {
861 GNUNET_asprintf (&full_name, 853 GNUNET_asprintf (&full_name, "%s%s%s%s", dn, DIR_SEPARATOR_STR, sfn,
862 "%s%s%s%s", 854 GNUNET_FS_DIRECTORY_EXT);
863 dn, DIR_SEPARATOR_STR, sfn, GNUNET_FS_DIRECTORY_EXT);
864 } 855 }
865 else 856 else
866 { 857 {
@@ -889,11 +880,7 @@ trigger_recursive_download (void *cls,
889 (unsigned int) 880 (unsigned int)
890 GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); 881 GNUNET_CONTAINER_meta_data_get_serialized_size (meta));
891#endif 882#endif
892 GNUNET_FS_download_start (dc->h, 883 GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0,
893 uri,
894 meta,
895 full_name, temp_name,
896 0,
897 GNUNET_FS_uri_chk_get_file_size (uri), 884 GNUNET_FS_uri_chk_get_file_size (uri),
898 dc->anonymity, dc->options, NULL, dc); 885 dc->anonymity, dc->options, NULL, dc);
899 GNUNET_free_non_null (full_name); 886 GNUNET_free_non_null (full_name);
@@ -931,8 +918,8 @@ GNUNET_FS_free_download_request_ (struct DownloadRequest *dr)
931 * @return GNUNET_YES (we should continue to iterate); unless serious error 918 * @return GNUNET_YES (we should continue to iterate); unless serious error
932 */ 919 */
933static int 920static int
934process_result_with_request (void *cls, 921process_result_with_request (void *cls, const GNUNET_HashCode * key,
935 const GNUNET_HashCode * key, void *value) 922 void *value)
936{ 923{
937 struct ProcessResultClosure *prc = cls; 924 struct ProcessResultClosure *prc = cls;
938 struct DownloadRequest *dr = value; 925 struct DownloadRequest *dr = value;
@@ -952,11 +939,9 @@ process_result_with_request (void *cls,
952#if DEBUG_DOWNLOAD 939#if DEBUG_DOWNLOAD
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 940 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
954 "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n", 941 "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n",
955 GNUNET_h2s (key), 942 GNUNET_h2s (key), dr->depth, (unsigned long long) dr->offset,
956 dr->depth, 943 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
957 (unsigned long long) dr->offset, 944 file_length));
958 (unsigned long long) GNUNET_ntohll (dc->uri->data.
959 chk.file_length));
960 945
961#endif 946#endif
962 bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll 947 bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll
@@ -968,8 +953,8 @@ process_result_with_request (void *cls,
968 _ 953 _
969 ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)\n"), 954 ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)\n"),
970 bs, dr->depth, (unsigned long long) dr->offset, 955 bs, dr->depth, (unsigned long long) dr->offset,
971 (unsigned long long) GNUNET_ntohll (dc->uri->data. 956 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
972 chk.file_length), 957 file_length),
973 prc->size); 958 prc->size);
974 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s", dc->emsg); 959 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s", dc->emsg);
975 while (dr->parent != NULL) 960 while (dr->parent != NULL)
@@ -996,18 +981,17 @@ process_result_with_request (void *cls,
996 dc->emsg = GNUNET_strdup (_("internal error decrypting content")); 981 dc->emsg = GNUNET_strdup (_("internal error decrypting content"));
997 goto signal_error; 982 goto signal_error;
998 } 983 }
999 off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length), 984 off =
1000 dr->offset, dr->depth); 985 compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length),
986 dr->offset, dr->depth);
1001 /* save to disk */ 987 /* save to disk */
1002 if ((GNUNET_YES == prc->do_store) && 988 if ((GNUNET_YES == prc->do_store) &&
1003 ((dc->filename != NULL) || 989 ((dc->filename != NULL) || (is_recursive_download (dc))) &&
1004 (is_recursive_download (dc))) &&
1005 ((dr->depth == dc->treedepth) || 990 ((dr->depth == dc->treedepth) ||
1006 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES)))) 991 (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES))))
1007 { 992 {
1008 fh = GNUNET_DISK_file_open (dc->filename != NULL 993 fh = GNUNET_DISK_file_open (dc->filename !=
1009 ? dc->filename 994 NULL ? dc->filename : dc->temp_filename,
1010 : dc->temp_filename,
1011 GNUNET_DISK_OPEN_READWRITE | 995 GNUNET_DISK_OPEN_READWRITE |
1012 GNUNET_DISK_OPEN_CREATE, 996 GNUNET_DISK_OPEN_CREATE,
1013 GNUNET_DISK_PERM_USER_READ | 997 GNUNET_DISK_PERM_USER_READ |
@@ -1030,8 +1014,8 @@ process_result_with_request (void *cls,
1030 { 1014 {
1031 GNUNET_asprintf (&dc->emsg, 1015 GNUNET_asprintf (&dc->emsg,
1032 _("Failed to seek to offset %llu in file `%s': %s\n"), 1016 _("Failed to seek to offset %llu in file `%s': %s\n"),
1033 (unsigned long long) off, 1017 (unsigned long long) off, dc->filename,
1034 dc->filename, STRERROR (errno)); 1018 STRERROR (errno));
1035 goto signal_error; 1019 goto signal_error;
1036 } 1020 }
1037 if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size)) 1021 if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size))
@@ -1072,9 +1056,8 @@ process_result_with_request (void *cls,
1072 * says it is a directory or if no meta data is given AND filename 1056 * says it is a directory or if no meta data is given AND filename
1073 * ends in '.gnd' (top-level case) */ 1057 * ends in '.gnd' (top-level case) */
1074 if (is_recursive_download (dc)) 1058 if (is_recursive_download (dc))
1075 GNUNET_FS_directory_list_contents (prc->size, 1059 GNUNET_FS_directory_list_contents (prc->size, pt, off,
1076 pt, 1060 &trigger_recursive_download, dc);
1077 off, &trigger_recursive_download, dc);
1078 1061
1079 } 1062 }
1080 dr->state = BRS_DOWNLOAD_DOWN; 1063 dr->state = BRS_DOWNLOAD_DOWN;
@@ -1094,16 +1077,17 @@ process_result_with_request (void *cls,
1094#if DEBUG_DOWNLOAD 1077#if DEBUG_DOWNLOAD
1095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1096 "Download completed, truncating file to desired length %llu\n", 1079 "Download completed, truncating file to desired length %llu\n",
1097 (unsigned long long) GNUNET_ntohll (dc->uri->data. 1080 (unsigned long long) GNUNET_ntohll (dc->uri->data.chk.
1098 chk.file_length)); 1081 file_length));
1099#endif 1082#endif
1100 /* truncate file to size (since we store IBlocks at the end) */ 1083 /* truncate file to size (since we store IBlocks at the end) */
1101 if (dc->filename != NULL) 1084 if (dc->filename != NULL)
1102 { 1085 {
1103 if (0 != truncate (dc->filename, 1086 if (0 !=
1104 GNUNET_ntohll (dc->uri->data.chk.file_length))) 1087 truncate (dc->filename,
1105 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1088 GNUNET_ntohll (dc->uri->data.chk.file_length)))
1106 "truncate", dc->filename); 1089 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate",
1090 dc->filename);
1107 } 1091 }
1108 GNUNET_assert (dr->depth == 0); 1092 GNUNET_assert (dr->depth == 0);
1109 check_completed (dc); 1093 check_completed (dc);
@@ -1212,8 +1196,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc,
1212 "Received result for query `%s' from `%s'-service\n", 1196 "Received result for query `%s' from `%s'-service\n",
1213 GNUNET_h2s (&prc.query), "FS"); 1197 GNUNET_h2s (&prc.query), "FS");
1214#endif 1198#endif
1215 GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, 1199 GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, &prc.query,
1216 &prc.query,
1217 &process_result_with_request, 1200 &process_result_with_request,
1218 &prc); 1201 &prc);
1219} 1202}
@@ -1233,8 +1216,7 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
1233 const struct PutMessage *cm; 1216 const struct PutMessage *cm;
1234 uint16_t msize; 1217 uint16_t msize;
1235 1218
1236 if ((NULL == msg) || 1219 if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
1237 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
1238 (sizeof (struct PutMessage) > ntohs (msg->size))) 1220 (sizeof (struct PutMessage) > ntohs (msg->size)))
1239 { 1221 {
1240 GNUNET_break (msg == NULL); 1222 GNUNET_break (msg == NULL);
@@ -1243,13 +1225,13 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg)
1243 } 1225 }
1244 msize = ntohs (msg->size); 1226 msize = ntohs (msg->size);
1245 cm = (const struct PutMessage *) msg; 1227 cm = (const struct PutMessage *) msg;
1246 process_result (dc, 1228 process_result (dc, ntohl (cm->type), &cm[1],
1247 ntohl (cm->type), &cm[1], msize - sizeof (struct PutMessage)); 1229 msize - sizeof (struct PutMessage));
1248 if (dc->client == NULL) 1230 if (dc->client == NULL)
1249 return; /* fatal error */ 1231 return; /* fatal error */
1250 /* continue receiving */ 1232 /* continue receiving */
1251 GNUNET_CLIENT_receive (dc->client, 1233 GNUNET_CLIENT_receive (dc->client, &receive_results, dc,
1252 &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); 1234 GNUNET_TIME_UNIT_FOREVER_REL);
1253} 1235}
1254 1236
1255 1237
@@ -1315,19 +1297,19 @@ transmit_download_request (void *cls, size_t size, void *buf)
1315 } 1297 }
1316 if (dc->pending_head != NULL) 1298 if (dc->pending_head != NULL)
1317 { 1299 {
1318 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 1300 dc->th =
1319 sizeof (struct SearchMessage), 1301 GNUNET_CLIENT_notify_transmit_ready (dc->client,
1320 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1302 sizeof (struct SearchMessage),
1321 GNUNET_NO, 1303 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1322 &transmit_download_request, 1304 GNUNET_NO,
1323 dc); 1305 &transmit_download_request, dc);
1324 GNUNET_assert (dc->th != NULL); 1306 GNUNET_assert (dc->th != NULL);
1325 } 1307 }
1326 if (GNUNET_NO == dc->in_receive) 1308 if (GNUNET_NO == dc->in_receive)
1327 { 1309 {
1328 dc->in_receive = GNUNET_YES; 1310 dc->in_receive = GNUNET_YES;
1329 GNUNET_CLIENT_receive (dc->client, 1311 GNUNET_CLIENT_receive (dc->client, &receive_results, dc,
1330 &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); 1312 GNUNET_TIME_UNIT_FOREVER_REL);
1331 } 1313 }
1332 return msize; 1314 return msize;
1333} 1315}
@@ -1357,12 +1339,12 @@ do_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1357 dc->client = client; 1339 dc->client = client;
1358 if (dc->pending_head != NULL) 1340 if (dc->pending_head != NULL)
1359 { 1341 {
1360 dc->th = GNUNET_CLIENT_notify_transmit_ready (client, 1342 dc->th =
1361 sizeof (struct SearchMessage), 1343 GNUNET_CLIENT_notify_transmit_ready (client,
1362 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1344 sizeof (struct SearchMessage),
1363 GNUNET_NO, 1345 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1364 &transmit_download_request, 1346 GNUNET_NO,
1365 dc); 1347 &transmit_download_request, dc);
1366 GNUNET_assert (dc->th != NULL); 1348 GNUNET_assert (dc->th != NULL);
1367 } 1349 }
1368} 1350}
@@ -1423,9 +1405,9 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
1423#if DEBUG_DOWNLOAD 1405#if DEBUG_DOWNLOAD
1424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n"); 1406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n");
1425#endif 1407#endif
1426 dc->task 1408 dc->task =
1427 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 1409 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect,
1428 &do_reconnect, dc); 1410 dc);
1429} 1411}
1430 1412
1431 1413
@@ -1459,12 +1441,12 @@ activate_fs_download (void *cls, struct GNUNET_CLIENT_Connection *client)
1459#endif 1441#endif
1460 if (dc->pending_head != NULL) 1442 if (dc->pending_head != NULL)
1461 { 1443 {
1462 dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, 1444 dc->th =
1463 sizeof (struct SearchMessage), 1445 GNUNET_CLIENT_notify_transmit_ready (dc->client,
1464 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1446 sizeof (struct SearchMessage),
1465 GNUNET_NO, 1447 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1466 &transmit_download_request, 1448 GNUNET_NO,
1467 dc); 1449 &transmit_download_request, dc);
1468 GNUNET_assert (dc->th != NULL); 1450 GNUNET_assert (dc->th != NULL);
1469 } 1451 }
1470} 1452}
@@ -1521,10 +1503,9 @@ deactivate_fs_download (void *cls)
1521 * the specified depth 1503 * the specified depth
1522 */ 1504 */
1523static struct DownloadRequest * 1505static struct DownloadRequest *
1524create_download_request (struct DownloadRequest *parent, 1506create_download_request (struct DownloadRequest *parent, unsigned int depth,
1525 unsigned int depth, 1507 uint64_t dr_offset, uint64_t file_start_offset,
1526 uint64_t dr_offset, 1508 uint64_t desired_length)
1527 uint64_t file_start_offset, uint64_t desired_length)
1528{ 1509{
1529 struct DownloadRequest *dr; 1510 struct DownloadRequest *dr;
1530 unsigned int i; 1511 unsigned int i;
@@ -1561,15 +1542,13 @@ create_download_request (struct DownloadRequest *parent,
1561 /* why else would we have gotten here to begin with? (that'd be a bad logic error) */ 1542 /* why else would we have gotten here to begin with? (that'd be a bad logic error) */
1562 GNUNET_assert (dr->num_children > 0); 1543 GNUNET_assert (dr->num_children > 0);
1563 1544
1564 dr->children = GNUNET_malloc (dr->num_children * 1545 dr->children =
1565 sizeof (struct DownloadRequest *)); 1546 GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *));
1566 for (i = 0; i < dr->num_children; i++) 1547 for (i = 0; i < dr->num_children; i++)
1567 dr->children[i] = create_download_request (dr, 1548 dr->children[i] =
1568 depth - 1, 1549 create_download_request (dr, depth - 1,
1569 dr_offset + 1550 dr_offset + i * child_block_size,
1570 i * child_block_size, 1551 file_start_offset, desired_length);
1571 file_start_offset,
1572 desired_length);
1573 } 1552 }
1574 return dr; 1553 return dr;
1575} 1554}
@@ -1643,11 +1622,8 @@ get_next_block (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1643 * @param block_size size of block (in bytes) 1622 * @param block_size size of block (in bytes)
1644 */ 1623 */
1645static void 1624static void
1646reconstruct_cb (void *cls, 1625reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset,
1647 const struct ContentHashKey *chk, 1626 unsigned int depth, enum GNUNET_BLOCK_Type type,
1648 uint64_t offset,
1649 unsigned int depth,
1650 enum GNUNET_BLOCK_Type type,
1651 const void *block, uint16_t block_size) 1627 const void *block, uint16_t block_size)
1652{ 1628{
1653 struct GNUNET_FS_DownloadContext *dc = cls; 1629 struct GNUNET_FS_DownloadContext *dc = cls;
@@ -1781,7 +1757,8 @@ GNUNET_FS_download_start_task_ (void *cls,
1781 GNUNET_DISK_OPEN_READWRITE | 1757 GNUNET_DISK_OPEN_READWRITE |
1782 GNUNET_DISK_OPEN_CREATE | 1758 GNUNET_DISK_OPEN_CREATE |
1783 ((0 == 1759 ((0 ==
1784 GNUNET_FS_uri_chk_get_file_size (dc->uri)) ? 1760 GNUNET_FS_uri_chk_get_file_size (dc->
1761 uri)) ?
1785 GNUNET_DISK_OPEN_TRUNCATE : 0), 1762 GNUNET_DISK_OPEN_TRUNCATE : 0),
1786 GNUNET_DISK_PERM_USER_READ | 1763 GNUNET_DISK_PERM_USER_READ |
1787 GNUNET_DISK_PERM_USER_WRITE | 1764 GNUNET_DISK_PERM_USER_WRITE |
@@ -1797,11 +1774,13 @@ GNUNET_FS_download_start_task_ (void *cls,
1797 return; 1774 return;
1798 if (dc->top_request == NULL) 1775 if (dc->top_request == NULL)
1799 { 1776 {
1800 dc->top_request = create_download_request (NULL, dc->treedepth - 1, 0, 1777 dc->top_request =
1801 dc->offset, dc->length); 1778 create_download_request (NULL, dc->treedepth - 1, 0, dc->offset,
1779 dc->length);
1802 dc->top_request->state = BRS_CHK_SET; 1780 dc->top_request->state = BRS_CHK_SET;
1803 dc->top_request->chk = (dc->uri->type == chk) 1781 dc->top_request->chk =
1804 ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk; 1782 (dc->uri->type ==
1783 chk) ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk;
1805 /* signal start */ 1784 /* signal start */
1806 GNUNET_FS_download_sync_ (dc); 1785 GNUNET_FS_download_sync_ (dc);
1807 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; 1786 pi.status = GNUNET_FS_STATUS_DOWNLOAD_START;
@@ -1811,9 +1790,9 @@ GNUNET_FS_download_start_task_ (void *cls,
1811 GNUNET_FS_download_start_downloading_ (dc); 1790 GNUNET_FS_download_start_downloading_ (dc);
1812 /* attempt reconstruction from disk */ 1791 /* attempt reconstruction from disk */
1813 if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename)) 1792 if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename))
1814 dc->rfh = GNUNET_DISK_file_open (dc->filename, 1793 dc->rfh =
1815 GNUNET_DISK_OPEN_READ, 1794 GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ,
1816 GNUNET_DISK_PERM_NONE); 1795 GNUNET_DISK_PERM_NONE);
1817 if (dc->top_request->state == BRS_CHK_SET) 1796 if (dc->top_request->state == BRS_CHK_SET)
1818 { 1797 {
1819 if (dc->rfh != NULL) 1798 if (dc->rfh != NULL)
@@ -1884,12 +1863,10 @@ GNUNET_FS_download_start_task_ (void *cls,
1884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1885 "Trying bottom-up reconstruction of file `%s'\n", dc->filename); 1864 "Trying bottom-up reconstruction of file `%s'\n", dc->filename);
1886#endif 1865#endif
1887 dc->te = GNUNET_FS_tree_encoder_create (dc->h, 1866 dc->te =
1888 dc->old_file_size, 1867 GNUNET_FS_tree_encoder_create (dc->h, dc->old_file_size, dc, &fh_reader,
1889 dc, 1868 &reconstruct_cb, NULL,
1890 &fh_reader, 1869 &reconstruct_cont);
1891 &reconstruct_cb,
1892 NULL, &reconstruct_cont);
1893 dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc); 1870 dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc);
1894 } 1871 }
1895 else 1872 else
@@ -1929,8 +1906,8 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
1929 dc->job_queue = NULL; 1906 dc->job_queue = NULL;
1930 } 1907 }
1931 if (dc->parent != NULL) 1908 if (dc->parent != NULL)
1932 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, 1909 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail,
1933 dc->parent->child_tail, dc); 1910 dc);
1934 if (dc->task != GNUNET_SCHEDULER_NO_TASK) 1911 if (dc->task != GNUNET_SCHEDULER_NO_TASK)
1935 { 1912 {
1936 GNUNET_SCHEDULER_cancel (dc->task); 1913 GNUNET_SCHEDULER_cancel (dc->task);
@@ -1997,13 +1974,10 @@ struct GNUNET_FS_DownloadContext *
1997GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 1974GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
1998 const struct GNUNET_FS_Uri *uri, 1975 const struct GNUNET_FS_Uri *uri,
1999 const struct GNUNET_CONTAINER_MetaData *meta, 1976 const struct GNUNET_CONTAINER_MetaData *meta,
2000 const char *filename, 1977 const char *filename, const char *tempname,
2001 const char *tempname, 1978 uint64_t offset, uint64_t length, uint32_t anonymity,
2002 uint64_t offset, 1979 enum GNUNET_FS_DownloadOptions options, void *cctx,
2003 uint64_t length, 1980 struct GNUNET_FS_DownloadContext *parent)
2004 uint32_t anonymity,
2005 enum GNUNET_FS_DownloadOptions options,
2006 void *cctx, struct GNUNET_FS_DownloadContext *parent)
2007{ 1981{
2008 struct GNUNET_FS_DownloadContext *dc; 1982 struct GNUNET_FS_DownloadContext *dc;
2009 1983
@@ -2016,8 +1990,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2016 return NULL; 1990 return NULL;
2017 } 1991 }
2018#if DEBUG_DOWNLOAD 1992#if DEBUG_DOWNLOAD
2019 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
2020 "Starting download `%s' of %llu bytes\n",
2021 filename, (unsigned long long) length); 1994 filename, (unsigned long long) length);
2022#endif 1995#endif
2023 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); 1996 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
@@ -2057,13 +2030,13 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2057 } 2030 }
2058 2031
2059#if DEBUG_DOWNLOAD 2032#if DEBUG_DOWNLOAD
2060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
2061 "Download tree has depth %u\n", dc->treedepth); 2034 dc->treedepth);
2062#endif 2035#endif
2063 if (parent == NULL) 2036 if (parent == NULL)
2064 { 2037 {
2065 dc->top = GNUNET_FS_make_top (dc->h, 2038 dc->top =
2066 &GNUNET_FS_download_signal_suspend_, dc); 2039 GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc);
2067 } 2040 }
2068 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); 2041 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
2069 return dc; 2042 return dc;
@@ -2108,10 +2081,8 @@ struct GNUNET_FS_DownloadContext *
2108GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, 2081GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2109 struct GNUNET_FS_SearchResult *sr, 2082 struct GNUNET_FS_SearchResult *sr,
2110 const char *filename, 2083 const char *filename,
2111 const char *tempname, 2084 const char *tempname, uint64_t offset,
2112 uint64_t offset, 2085 uint64_t length, uint32_t anonymity,
2113 uint64_t length,
2114 uint32_t anonymity,
2115 enum GNUNET_FS_DownloadOptions options, 2086 enum GNUNET_FS_DownloadOptions options,
2116 void *cctx) 2087 void *cctx)
2117{ 2088{
@@ -2131,8 +2102,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2131 return NULL; 2102 return NULL;
2132 } 2103 }
2133#if DEBUG_DOWNLOAD 2104#if DEBUG_DOWNLOAD
2134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n",
2135 "Starting download `%s' of %llu bytes\n",
2136 filename, (unsigned long long) length); 2106 filename, (unsigned long long) length);
2137#endif 2107#endif
2138 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); 2108 dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext));
@@ -2174,8 +2144,8 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2174 } 2144 }
2175 2145
2176#if DEBUG_DOWNLOAD 2146#if DEBUG_DOWNLOAD
2177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n",
2178 "Download tree has depth %u\n", dc->treedepth); 2148 dc->treedepth);
2179#endif 2149#endif
2180 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); 2150 dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc);
2181 return dc; 2151 return dc;
@@ -2193,12 +2163,9 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc)
2193 if (dc->completed == dc->length) 2163 if (dc->completed == dc->length)
2194 return; 2164 return;
2195 GNUNET_assert (dc->job_queue == NULL); 2165 GNUNET_assert (dc->job_queue == NULL);
2196 dc->job_queue = GNUNET_FS_queue_ (dc->h, 2166 dc->job_queue =
2197 &activate_fs_download, 2167 GNUNET_FS_queue_ (dc->h, &activate_fs_download, &deactivate_fs_download,
2198 &deactivate_fs_download, 2168 dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE);
2199 dc,
2200 (dc->length + DBLOCK_SIZE -
2201 1) / DBLOCK_SIZE);
2202} 2169}
2203 2170
2204 2171
@@ -2242,19 +2209,20 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2242 while (NULL != dc->child_head) 2209 while (NULL != dc->child_head)
2243 GNUNET_FS_download_stop (dc->child_head, do_delete); 2210 GNUNET_FS_download_stop (dc->child_head, do_delete);
2244 if (dc->parent != NULL) 2211 if (dc->parent != NULL)
2245 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, 2212 GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail,
2246 dc->parent->child_tail, dc); 2213 dc);
2247 if (dc->serialization != NULL) 2214 if (dc->serialization != NULL)
2248 GNUNET_FS_remove_sync_file_ (dc->h, 2215 GNUNET_FS_remove_sync_file_ (dc->h,
2249 ((dc->parent != NULL) || (dc->search != NULL)) 2216 ((dc->parent != NULL) ||
2250 ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD 2217 (dc->search !=
2251 : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 2218 NULL)) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
2219 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
2252 dc->serialization); 2220 dc->serialization);
2253 if ((GNUNET_YES == have_children) && (dc->parent == NULL)) 2221 if ((GNUNET_YES == have_children) && (dc->parent == NULL))
2254 GNUNET_FS_remove_sync_dir_ (dc->h, 2222 GNUNET_FS_remove_sync_dir_ (dc->h,
2255 (dc->search != NULL) 2223 (dc->search !=
2256 ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD 2224 NULL) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD :
2257 : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, 2225 GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD,
2258 dc->serialization); 2226 dc->serialization);
2259 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; 2227 pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED;
2260 GNUNET_FS_download_make_status_ (&pi, dc); 2228 GNUNET_FS_download_make_status_ (&pi, dc);
@@ -2270,8 +2238,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2270 if ((dc->completed != dc->length) && (GNUNET_YES == do_delete)) 2238 if ((dc->completed != dc->length) && (GNUNET_YES == do_delete))
2271 { 2239 {
2272 if (0 != UNLINK (dc->filename)) 2240 if (0 != UNLINK (dc->filename))
2273 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 2241 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
2274 "unlink", dc->filename); 2242 dc->filename);
2275 } 2243 }
2276 GNUNET_free (dc->filename); 2244 GNUNET_free (dc->filename);
2277 } 2245 }
@@ -2280,8 +2248,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2280 if (NULL != dc->temp_filename) 2248 if (NULL != dc->temp_filename)
2281 { 2249 {
2282 if (0 != UNLINK (dc->temp_filename)) 2250 if (0 != UNLINK (dc->temp_filename))
2283 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 2251 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink",
2284 "unlink", dc->temp_filename); 2252 dc->temp_filename);
2285 GNUNET_free (dc->temp_filename); 2253 GNUNET_free (dc->temp_filename);
2286 } 2254 }
2287 GNUNET_free_non_null (dc->serialization); 2255 GNUNET_free_non_null (dc->serialization);