aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-02 19:49:23 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-02 19:49:23 +0000
commitbec64fd32ad5f930ee60634103222c4575904728 (patch)
treebbc3b1eb41e2f315baef4186d4b3c06cebb5271b /src
parent8922e187c0d77dfa7cbd56440b10de5670d9d311 (diff)
downloadgnunet-bec64fd32ad5f930ee60634103222c4575904728.tar.gz
gnunet-bec64fd32ad5f930ee60634103222c4575904728.zip
more
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs_unindex.c82
-rw-r--r--src/include/gnunet_fs_service.h14
2 files changed, 95 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 */
89static void
90process_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 */
175static void 227static void
176unindex_finish (void *cls, 228unindex_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
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 994c6eb15..8f7c67407 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -628,6 +628,12 @@ enum GNUNET_FS_Status
628 628
629 /** 629 /**
630 * Notification that the unindexing of this file 630 * Notification that the unindexing of this file
631 * was completed.
632 */
633 GNUNET_FS_STATUS_UNINDEX_COMPLETED,
634
635 /**
636 * Notification that the unindexing of this file
631 * was stopped (final event for this action). 637 * was stopped (final event for this action).
632 */ 638 */
633 GNUNET_FS_STATUS_UNINDEX_STOPPED 639 GNUNET_FS_STATUS_UNINDEX_STOPPED
@@ -770,6 +776,14 @@ struct GNUNET_FS_ProgressInfo
770 */ 776 */
771 uint64_t data_len; 777 uint64_t data_len;
772 778
779 /**
780 * Depth of the given block in the tree;
781 * 0 would be the highest level (the first
782 * call is guaranteed to be for the lowest
783 * level).
784 */
785 unsigned int depth;
786
773 } progress; 787 } progress;
774 788
775 /** 789 /**