diff options
Diffstat (limited to 'src/fs/fs_download.c')
-rw-r--r-- | src/fs/fs_download.c | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 289599471..1399cf8dd 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include "fs.h" | 36 | #include "fs.h" |
37 | #include "fs_tree.h" | 37 | #include "fs_tree.h" |
38 | 38 | ||
39 | #define DEBUG_DOWNLOAD GNUNET_NO | 39 | #define DEBUG_DOWNLOAD GNUNET_YES |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * We're storing the IBLOCKS after the | 42 | * We're storing the IBLOCKS after the |
@@ -65,9 +65,9 @@ compute_disk_offset (uint64_t fsize, | |||
65 | unsigned int treedepth) | 65 | unsigned int treedepth) |
66 | { | 66 | { |
67 | unsigned int i; | 67 | unsigned int i; |
68 | uint64_t lsize; /* what is the size of all IBlocks for level "i"? */ | 68 | uint64_t lsize; /* what is the size of all IBlocks for depth "i"? */ |
69 | uint64_t loff; /* where do IBlocks for level "i" start? */ | 69 | uint64_t loff; /* where do IBlocks for depth "i" start? */ |
70 | unsigned int ioff; /* which IBlock corresponds to "off" at level "i"? */ | 70 | unsigned int ioff; /* which IBlock corresponds to "off" at depth "i"? */ |
71 | 71 | ||
72 | if (depth == treedepth) | 72 | if (depth == treedepth) |
73 | return off; | 73 | return off; |
@@ -113,7 +113,7 @@ compute_dblock_offset (uint64_t offset, | |||
113 | { | 113 | { |
114 | unsigned int i; | 114 | unsigned int i; |
115 | uint64_t lsize; /* what is the size of the sum of all DBlocks | 115 | uint64_t lsize; /* what is the size of the sum of all DBlocks |
116 | that a CHK at level i corresponds to? */ | 116 | that a CHK at depth i corresponds to? */ |
117 | 117 | ||
118 | if (depth == treedepth) | 118 | if (depth == treedepth) |
119 | return offset; | 119 | return offset; |
@@ -504,7 +504,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc, | |||
504 | } | 504 | } |
505 | #if DEBUG_DOWNLOAD | 505 | #if DEBUG_DOWNLOAD |
506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
507 | "Triggering downloads of children (this block was at level %u and offset %llu)\n", | 507 | "Triggering downloads of children (this block was at depth %u and offset %llu)\n", |
508 | sm->depth, | 508 | sm->depth, |
509 | (unsigned long long) sm->offset); | 509 | (unsigned long long) sm->offset); |
510 | #endif | 510 | #endif |
@@ -920,61 +920,4 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, | |||
920 | GNUNET_free (dc); | 920 | GNUNET_free (dc); |
921 | } | 921 | } |
922 | 922 | ||
923 | |||
924 | |||
925 | #if 0 | ||
926 | |||
927 | |||
928 | /** | ||
929 | * Check if self block is already present on the drive. If the block | ||
930 | * is a dblock and present, the ProgressModel is notified. If the | ||
931 | * block is present and it is an iblock, downloading the children is | ||
932 | * triggered. | ||
933 | * | ||
934 | * Also checks if the block is within the range of blocks | ||
935 | * that we are supposed to download. If not, the method | ||
936 | * returns as if the block is present but does NOT signal | ||
937 | * progress. | ||
938 | * | ||
939 | * @param node that is checked for presence | ||
940 | * @return GNUNET_YES if present, GNUNET_NO if not. | ||
941 | */ | ||
942 | static int | ||
943 | check_node_present (const struct Node *node) | ||
944 | { | ||
945 | int res; | ||
946 | int ret; | ||
947 | char *data; | ||
948 | unsigned int size; | ||
949 | GNUNET_HashCode hc; | ||
950 | |||
951 | size = get_node_size (node); | ||
952 | /* first check if node is within range. | ||
953 | For now, keeping it simple, we only do | ||
954 | this for level-0 nodes */ | ||
955 | if ((node->level == 0) && | ||
956 | ((node->offset + size < node->ctx->offset) || | ||
957 | (node->offset >= node->ctx->offset + node->ctx->length))) | ||
958 | return GNUNET_YES; | ||
959 | data = GNUNET_malloc (size); | ||
960 | ret = GNUNET_NO; | ||
961 | res = read_from_files (node->ctx, node->level, node->offset, data, size); | ||
962 | if (res == size) | ||
963 | { | ||
964 | GNUNET_hash (data, size, &hc); | ||
965 | if (0 == memcmp (&hc, &node->chk.key, sizeof (GNUNET_HashCode))) | ||
966 | { | ||
967 | notify_client_about_progress (node, data, size); | ||
968 | if (node->level > 0) | ||
969 | iblock_download_children (node, data, size); | ||
970 | ret = GNUNET_YES; | ||
971 | } | ||
972 | } | ||
973 | GNUNET_free (data); | ||
974 | return ret; | ||
975 | } | ||
976 | |||
977 | #endif | ||
978 | |||
979 | |||
980 | /* end of fs_download.c */ | 923 | /* end of fs_download.c */ |