diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-09-02 19:49:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-09-02 19:49:23 +0000 |
commit | bec64fd32ad5f930ee60634103222c4575904728 (patch) | |
tree | bbc3b1eb41e2f315baef4186d4b3c06cebb5271b /src/fs/fs_unindex.c | |
parent | 8922e187c0d77dfa7cbd56440b10de5670d9d311 (diff) | |
download | gnunet-bec64fd32ad5f930ee60634103222c4575904728.tar.gz gnunet-bec64fd32ad5f930ee60634103222c4575904728.zip |
more
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r-- | src/fs/fs_unindex.c | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 1416667f3..a6d414f09 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -79,6 +79,26 @@ unindex_reader (void *cls, | |||
79 | 79 | ||
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Continuation called to notify client about result of the | ||
83 | * datastore removal operation. | ||
84 | * | ||
85 | * @param cls closure | ||
86 | * @param success GNUNET_SYSERR on failure | ||
87 | * @param msg NULL on success, otherwise an error message | ||
88 | */ | ||
89 | static void | ||
90 | process_cont (void *cls, | ||
91 | int success, | ||
92 | const char *msg) | ||
93 | { | ||
94 | struct GNUNET_FS_UnindexContext *uc = cls; | ||
95 | // FIXME: may want to check for errors | ||
96 | // OTHER than content-not-present! | ||
97 | GNUNET_FS_tree_encoder_next (uc->tc); | ||
98 | } | ||
99 | |||
100 | |||
101 | /** | ||
82 | * Function called asking for the current (encoded) | 102 | * Function called asking for the current (encoded) |
83 | * block to be processed. After processing the | 103 | * block to be processed. After processing the |
84 | * client should either call "GNUNET_FS_tree_encode_next" | 104 | * client should either call "GNUNET_FS_tree_encode_next" |
@@ -99,6 +119,30 @@ unindex_process (void *cls, | |||
99 | const void *block, | 119 | const void *block, |
100 | uint16_t block_size) | 120 | uint16_t block_size) |
101 | { | 121 | { |
122 | struct GNUNET_FS_UnindexContext *uc = cls; | ||
123 | uint32_t size; | ||
124 | const void *data; | ||
125 | struct OnDemandBlock odb; | ||
126 | |||
127 | if (type != GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) | ||
128 | { | ||
129 | size = block_size; | ||
130 | data = block; | ||
131 | } | ||
132 | else /* on-demand encoded DBLOCK */ | ||
133 | { | ||
134 | size = sizeof(struct OnDemandBlock); | ||
135 | odb.offset = offset; | ||
136 | odb.file_id = uc->file_id; | ||
137 | data = &odb; | ||
138 | } | ||
139 | GNUNET_DATASTORE_remove (uc->dsh, | ||
140 | query, | ||
141 | block_size, | ||
142 | block, | ||
143 | &process_cont, | ||
144 | uc, | ||
145 | GNUNET_CONSTANTS_SERVICE_TIMEOUT); | ||
102 | } | 146 | } |
103 | 147 | ||
104 | 148 | ||
@@ -119,7 +163,8 @@ unindex_progress (void *cls, | |||
119 | size_t pt_size, | 163 | size_t pt_size, |
120 | unsigned int depth) | 164 | unsigned int depth) |
121 | { | 165 | { |
122 | // FIXME | 166 | struct GNUNET_FS_UnindexContext *uc = cls; |
167 | // FIXME: call callback! | ||
123 | } | 168 | } |
124 | 169 | ||
125 | 170 | ||
@@ -172,10 +217,45 @@ signal_unindex_error (struct GNUNET_FS_UnindexContext *uc, | |||
172 | } | 217 | } |
173 | 218 | ||
174 | 219 | ||
220 | /** | ||
221 | * Function called when the tree encoder has | ||
222 | * processed all blocks. Clean up. | ||
223 | * | ||
224 | * @param cls our unindexing context | ||
225 | * @param tc not used | ||
226 | */ | ||
175 | static void | 227 | static void |
176 | unindex_finish (void *cls, | 228 | unindex_finish (void *cls, |
177 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 229 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
178 | { | 230 | { |
231 | struct GNUNET_FS_UnindexContext *uc = cls; | ||
232 | char *emsg; | ||
233 | struct GNUNET_FS_Uri *uri; | ||
234 | struct GNUNET_FS_ProgressInfo pi; | ||
235 | |||
236 | GNUNET_FS_tree_encoder_finish (uc->tc, | ||
237 | &uri, | ||
238 | &emsg); | ||
239 | if (uri != NULL) | ||
240 | GNUNET_FS_uri_destroy (uri); | ||
241 | GNUNET_DISK_file_close (uc->fh); | ||
242 | uc->fh = NULL; | ||
243 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); | ||
244 | uc->dsh = NULL; | ||
245 | if (emsg != NULL) | ||
246 | { | ||
247 | signal_unindex_error (uc, emsg); | ||
248 | GNUNET_free (emsg); | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED; | ||
253 | make_unindex_status (&pi, uc, uc->file_size); | ||
254 | pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; | ||
255 | uc->client_info | ||
256 | = uc->h->upcb (uc->h->upcb_cls, | ||
257 | &pi); | ||
258 | } | ||
179 | } | 259 | } |
180 | 260 | ||
181 | 261 | ||