2 This file is part of GNUnet.
3 (C) 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/fs_unindex.c
23 * @author Krista Grothoff
24 * @author Christian Grothoff
25 * @brief Unindex file.
28 #include "gnunet_constants.h"
29 #include "gnunet_fs_service.h"
30 #include "gnunet_protocols.h"
37 * Function called by the tree encoder to obtain
38 * a block of plaintext data (for the lowest level
41 * @param cls our publishing context
42 * @param offset identifies which block to get
43 * @param max (maximum) number of bytes to get; returning
44 * fewer will also cause errors
45 * @param buf where to copy the plaintext buffer
46 * @param emsg location to store an error message (on error)
47 * @return number of bytes copied to buf, 0 on error
50 unindex_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
52 struct GNUNET_FS_UnindexContext *uc = cls;
55 pt_size = GNUNET_MIN (max, uc->file_size - offset);
56 if (offset != GNUNET_DISK_file_seek (uc->fh, offset, GNUNET_DISK_SEEK_SET))
58 *emsg = GNUNET_strdup (_("Failed to find given position in file"));
61 if (pt_size != GNUNET_DISK_file_read (uc->fh, buf, pt_size))
63 *emsg = GNUNET_strdup (_("Failed to read file"));
71 * Fill in all of the generic fields for
72 * an unindex event and call the callback.
74 * @param pi structure to fill in
75 * @param uc overall unindex context
76 * @param offset where we are in the file (for progress)
79 GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
80 struct GNUNET_FS_UnindexContext *uc,
83 pi->value.unindex.uc = uc;
84 pi->value.unindex.cctx = uc->client_info;
85 pi->value.unindex.filename = uc->filename;
86 pi->value.unindex.size = uc->file_size;
87 pi->value.unindex.eta =
88 GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size);
89 pi->value.unindex.duration =
90 GNUNET_TIME_absolute_get_duration (uc->start_time);
91 pi->value.unindex.completed = offset;
92 uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
98 * Function called with information about our
99 * progress in computing the tree encoding.
102 * @param offset where are we in the file
103 * @param pt_block plaintext of the currently processed block
104 * @param pt_size size of pt_block
105 * @param depth depth of the block in the tree, 0 for DBLOCK
108 unindex_progress (void *cls, uint64_t offset, const void *pt_block,
109 size_t pt_size, unsigned int depth)
111 struct GNUNET_FS_UnindexContext *uc = cls;
112 struct GNUNET_FS_ProgressInfo pi;
114 pi.status = GNUNET_FS_STATUS_UNINDEX_PROGRESS;
115 pi.value.unindex.specifics.progress.data = pt_block;
116 pi.value.unindex.specifics.progress.offset = offset;
117 pi.value.unindex.specifics.progress.data_len = pt_size;
118 pi.value.unindex.specifics.progress.depth = depth;
119 GNUNET_FS_unindex_make_status_ (&pi, uc, offset);
124 * We've encountered an error during
125 * unindexing. Signal the client.
127 * @param uc context for the failed unindexing operation
130 signal_unindex_error (struct GNUNET_FS_UnindexContext *uc)
132 struct GNUNET_FS_ProgressInfo pi;
134 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR;
135 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
136 pi.value.unindex.specifics.error.message = uc->emsg;
137 GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
142 * Continuation called to notify client about result of the
143 * datastore removal operation.
146 * @param success GNUNET_SYSERR on failure
147 * @param min_expiration minimum expiration time required for content to be stored
148 * @param msg NULL on success, otherwise an error message
151 process_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
153 struct GNUNET_FS_UnindexContext *uc = cls;
155 if (success == GNUNET_SYSERR)
157 uc->emsg = GNUNET_strdup (msg);
158 signal_unindex_error (uc);
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
162 "Datastore REMOVE operation succeeded\n");
163 GNUNET_FS_tree_encoder_next (uc->tc);
168 * Function called asking for the current (encoded)
169 * block to be processed. After processing the
170 * client should either call "GNUNET_FS_tree_encode_next"
171 * or (on error) "GNUNET_FS_tree_encode_finish".
174 * @param chk content hash key for the block (key for lookup in the datastore)
175 * @param offset offset of the block
176 * @param depth depth of the block, 0 for DBLOCK
177 * @param type type of the block (IBLOCK or DBLOCK)
178 * @param block the (encrypted) block
179 * @param block_size size of block (in bytes)
182 unindex_process (void *cls, const struct ContentHashKey *chk, uint64_t offset,
183 unsigned int depth, enum GNUNET_BLOCK_Type type,
184 const void *block, uint16_t block_size)
186 struct GNUNET_FS_UnindexContext *uc = cls;
189 struct OnDemandBlock odb;
191 if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK)
196 else /* on-demand encoded DBLOCK */
198 size = sizeof (struct OnDemandBlock);
199 odb.offset = GNUNET_htonll (offset);
200 odb.file_id = uc->file_id;
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
204 "Sending REMOVE request to DATASTORE service\n");
205 GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
206 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc);
212 * Function called with the response from the
213 * FS service to our unindexing request.
215 * @param cls closure, unindex context
216 * @param msg NULL on timeout, otherwise the response
219 process_fs_response (void *cls, const struct GNUNET_MessageHeader *msg)
221 struct GNUNET_FS_UnindexContext *uc = cls;
222 struct GNUNET_FS_ProgressInfo pi;
224 if (uc->client != NULL)
226 GNUNET_CLIENT_disconnect (uc->client);
229 if (uc->state != UNINDEX_STATE_FS_NOTIFY)
231 uc->state = UNINDEX_STATE_ERROR;
233 GNUNET_strdup (_("Unexpected time for a response from `fs' service."));
234 GNUNET_FS_unindex_sync_ (uc);
235 signal_unindex_error (uc);
240 uc->state = UNINDEX_STATE_ERROR;
241 uc->emsg = GNUNET_strdup (_("Timeout waiting for `fs' service."));
242 GNUNET_FS_unindex_sync_ (uc);
243 signal_unindex_error (uc);
246 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK)
248 uc->state = UNINDEX_STATE_ERROR;
249 uc->emsg = GNUNET_strdup (_("Invalid response from `fs' service."));
250 GNUNET_FS_unindex_sync_ (uc);
251 signal_unindex_error (uc);
254 uc->state = UNINDEX_STATE_COMPLETE;
255 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED;
256 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
257 GNUNET_FS_unindex_sync_ (uc);
258 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size);
263 * Function called when we are done with removing KBlocks.
264 * Disconnect from datastore and notify FS service about
267 * @param uc our unindexing context
270 unindex_finish (struct GNUNET_FS_UnindexContext *uc)
273 struct GNUNET_FS_Uri *uri;
274 struct UnindexMessage req;
276 /* generate final progress message */
277 unindex_progress (uc, uc->file_size, NULL, 0, 0);
278 GNUNET_FS_tree_encoder_finish (uc->tc, &uri, &emsg);
281 GNUNET_FS_uri_destroy (uri);
282 GNUNET_DISK_file_close (uc->fh);
284 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
286 uc->state = UNINDEX_STATE_FS_NOTIFY;
287 GNUNET_FS_unindex_sync_ (uc);
288 uc->client = GNUNET_CLIENT_connect ("fs", uc->h->cfg);
289 if (uc->client == NULL)
291 uc->state = UNINDEX_STATE_ERROR;
293 GNUNET_strdup (_("Failed to connect to FS service for unindexing."));
294 GNUNET_FS_unindex_sync_ (uc);
295 signal_unindex_error (uc);
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
299 "Sending UNINDEX message to FS service\n");
300 req.header.size = htons (sizeof (struct UnindexMessage));
301 req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
303 req.file_id = uc->file_id;
304 GNUNET_break (GNUNET_OK ==
305 GNUNET_CLIENT_transmit_and_get_response (uc->client,
307 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
309 &process_fs_response,
316 * Function called by the directory scanner as we extract keywords
317 * that we will need to remove KBlocks.
319 * @param cls the 'struct GNUNET_FS_UnindexContext *'
320 * @param filename which file we are making progress on
321 * @param is_directory GNUNET_YES if this is a directory,
322 * GNUNET_NO if this is a file
323 * GNUNET_SYSERR if it is neither (or unknown)
324 * @param reason kind of progress we are making
327 unindex_directory_scan_cb (void *cls,
328 const char *filename,
330 enum GNUNET_FS_DirScannerProgressUpdateReason reason)
332 struct GNUNET_FS_UnindexContext *uc = cls;
333 static struct GNUNET_FS_ShareTreeItem * directory_scan_result;
337 case GNUNET_FS_DIRSCANNER_FINISHED:
338 directory_scan_result = GNUNET_FS_directory_scan_get_result (uc->dscan);
340 if (NULL != directory_scan_result->ksk_uri)
342 uc->ksk_uri = GNUNET_FS_uri_dup (directory_scan_result->ksk_uri);
343 uc->state = UNINDEX_STATE_DS_REMOVE_KBLOCKS;
344 GNUNET_FS_unindex_sync_ (uc);
345 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
349 uc->emsg = GNUNET_strdup (_("Failed to get KSKs from directory scan."));
350 GNUNET_FS_unindex_sync_ (uc);
353 GNUNET_FS_share_tree_free (directory_scan_result);
355 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
356 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
357 _("Internal error scanning `%s'.\n"),
359 GNUNET_FS_directory_scan_abort (uc->dscan);
361 uc->emsg = GNUNET_strdup (_("Failed to get KSKs from directory scan."));
362 GNUNET_FS_unindex_sync_ (uc);
372 * If necessary, connect to the datastore and remove the KBlocks.
374 * @param uc context for the unindex operation.
377 GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc)
382 GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS", &ex))
384 uc->dscan = GNUNET_FS_directory_scan_start (uc->filename,
386 &unindex_directory_scan_cb,
388 GNUNET_free_non_null (ex);
393 * Continuation called to notify client about result of the remove
394 * operation for the KBlock.
396 * @param cls the 'struct GNUNET_FS_UnindexContext *'
397 * @param success GNUNET_SYSERR on failure (including timeout/queue drop)
398 * GNUNET_NO if content was already there
399 * GNUNET_YES (or other positive value) on success
400 * @param min_expiration minimum expiration time required for 0-priority content to be stored
401 * by the datacache at this time, zero for unknown, forever if we have no
402 * space for 0-priority content
403 * @param msg NULL on success, otherwise an error message
406 continue_after_remove (void *cls,
408 struct GNUNET_TIME_Absolute min_expiration,
411 struct GNUNET_FS_UnindexContext *uc = cls;
414 if (success != GNUNET_YES)
415 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
416 _("Failed to remove KBlock: %s\n"),
419 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
424 * Function called from datastore with result from us looking for
425 * a KBlock. There are four cases:
426 * 1) no result, means we move on to the next keyword
427 * 2) UID is the same as the first UID, means we move on to next keyword
428 * 3) KBlock for a different CHK, means we keep looking for more
429 * 4) KBlock is for our CHK, means we remove the block and then move
430 * on to the next keyword
432 * @param cls the 'struct GNUNET_FS_UnindexContext *'
433 * @param key key for the content
434 * @param size number of bytes in data
435 * @param data content stored
436 * @param type type of the content
437 * @param priority priority of the content
438 * @param anonymity anonymity-level for the content
439 * @param expiration expiration time for the content
440 * @param uid unique identifier for the datum;
441 * maybe 0 if no unique identifier is available
444 process_kblock_for_unindex (void *cls,
445 const struct GNUNET_HashCode * key,
446 size_t size, const void *data,
447 enum GNUNET_BLOCK_Type type,
450 struct GNUNET_TIME_Absolute
451 expiration, uint64_t uid)
453 struct GNUNET_FS_UnindexContext *uc = cls;
454 const struct KBlock *kb;
455 struct GNUNET_FS_Uri *chk_uri;
462 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
465 if (0 == uc->first_uid)
467 /* remember UID of first result to detect cycles */
470 else if (uid == uc->first_uid)
472 /* no more additional results */
474 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
477 GNUNET_assert (GNUNET_BLOCK_TYPE_FS_KBLOCK == type);
478 if (size < sizeof (struct KBlock))
485 char pt[size - sizeof (struct KBlock)];
486 struct GNUNET_CRYPTO_AesSessionKey skey;
487 struct GNUNET_CRYPTO_AesInitializationVector iv;
489 GNUNET_CRYPTO_hash_to_aes_key (&uc->key, &skey, &iv);
491 GNUNET_CRYPTO_aes_decrypt (&kb[1], size - sizeof (struct KBlock), &skey,
497 if (NULL == memchr (pt, 0, sizeof (pt)))
502 chk_uri = GNUNET_FS_uri_parse (pt, NULL);
505 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
506 _("Failed to parse URI `%s' from KBlock!\n"),
512 if (0 != memcmp (&uc->chk,
513 &chk_uri->data.chk.chk,
514 sizeof (struct ContentHashKey)))
516 /* different CHK, ignore */
517 GNUNET_FS_uri_destroy (chk_uri);
520 GNUNET_FS_uri_destroy (chk_uri);
522 uc->dqe = GNUNET_DATASTORE_remove (uc->dsh,
524 0 /* priority */, 1 /* queue size */,
525 GNUNET_TIME_UNIT_FOREVER_REL,
526 &continue_after_remove,
530 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
533 GNUNET_BLOCK_TYPE_FS_KBLOCK,
534 0 /* priority */, 1 /* queue size */,
535 GNUNET_TIME_UNIT_FOREVER_REL,
536 &process_kblock_for_unindex,
542 * If necessary, connect to the datastore and remove the KBlocks.
544 * @param uc context for the unindex operation.
547 GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
550 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
551 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
554 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
557 uc->state = UNINDEX_STATE_ERROR;
558 uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service."));
559 GNUNET_FS_unindex_sync_ (uc);
560 signal_unindex_error (uc);
563 if ( (NULL == uc->ksk_uri) ||
564 (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount) )
569 /* FIXME: code duplication with fs_search.c here... */
570 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
571 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->key);
572 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&uc->key);
573 GNUNET_assert (pk != NULL);
574 GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
575 GNUNET_CRYPTO_rsa_key_free (pk);
576 GNUNET_CRYPTO_hash (&pub,
578 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
581 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
584 GNUNET_BLOCK_TYPE_FS_KBLOCK,
585 0 /* priority */, 1 /* queue size */,
586 GNUNET_TIME_UNIT_FOREVER_REL,
587 &process_kblock_for_unindex,
593 * Function called when the tree encoder has
594 * processed all blocks. Clean up.
596 * @param cls our unindexing context
600 unindex_extract_keywords (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
602 struct GNUNET_FS_UnindexContext *uc = cls;
604 uc->state = UNINDEX_STATE_EXTRACT_KEYWORDS;
605 GNUNET_FS_unindex_sync_ (uc);
606 GNUNET_FS_unindex_do_extract_keywords_ (uc);
611 * Connect to the datastore and remove the blocks.
613 * @param uc context for the unindex operation.
616 GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
619 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
622 uc->state = UNINDEX_STATE_ERROR;
623 uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service."));
624 GNUNET_FS_unindex_sync_ (uc);
625 signal_unindex_error (uc);
629 GNUNET_DISK_file_open (uc->filename, GNUNET_DISK_OPEN_READ,
630 GNUNET_DISK_PERM_NONE);
633 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
635 uc->state = UNINDEX_STATE_ERROR;
636 uc->emsg = GNUNET_strdup (_("Failed to open file for unindexing."));
637 GNUNET_FS_unindex_sync_ (uc);
638 signal_unindex_error (uc);
642 GNUNET_FS_tree_encoder_create (uc->h, uc->file_size, uc, &unindex_reader,
643 &unindex_process, &unindex_progress,
644 &unindex_extract_keywords);
645 GNUNET_FS_tree_encoder_next (uc->tc);
650 * Function called once the hash of the file
651 * that is being unindexed has been computed.
653 * @param cls closure, unindex context
654 * @param file_id computed hash, NULL on error
657 GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode * file_id)
659 struct GNUNET_FS_UnindexContext *uc = cls;
662 if (uc->state != UNINDEX_STATE_HASHING)
664 GNUNET_FS_unindex_stop (uc);
669 uc->state = UNINDEX_STATE_ERROR;
670 uc->emsg = GNUNET_strdup (_("Failed to compute hash of file."));
671 GNUNET_FS_unindex_sync_ (uc);
672 signal_unindex_error (uc);
675 uc->file_id = *file_id;
676 uc->state = UNINDEX_STATE_DS_REMOVE;
677 GNUNET_FS_unindex_sync_ (uc);
678 GNUNET_FS_unindex_do_remove_ (uc);
683 * Create SUSPEND event for the given unindex operation
684 * and then clean up our state (without stop signal).
686 * @param cls the 'struct GNUNET_FS_UnindexContext' to signal for
689 GNUNET_FS_unindex_signal_suspend_ (void *cls)
691 struct GNUNET_FS_UnindexContext *uc = cls;
692 struct GNUNET_FS_ProgressInfo pi;
694 /* FIXME: lots of duplication with unindex_stop here! */
695 if (uc->dscan != NULL)
697 GNUNET_FS_directory_scan_abort (uc->dscan);
702 GNUNET_DATASTORE_cancel (uc->dqe);
707 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
710 if (NULL != uc->ksk_uri)
712 GNUNET_FS_uri_destroy (uc->ksk_uri);
715 if (uc->client != NULL)
717 GNUNET_CLIENT_disconnect (uc->client);
722 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
727 GNUNET_FS_tree_encoder_finish (uc->tc, NULL, NULL);
732 GNUNET_DISK_file_close (uc->fh);
735 GNUNET_FS_end_top (uc->h, uc->top);
736 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
737 GNUNET_FS_unindex_make_status_ (&pi, uc,
739 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
740 GNUNET_break (NULL == uc->client_info);
741 GNUNET_free (uc->filename);
742 GNUNET_free_non_null (uc->serialization);
743 GNUNET_free_non_null (uc->emsg);
751 * @param h handle to the file sharing subsystem
752 * @param filename file to unindex
753 * @param cctx initial value for the client context
754 * @return NULL on error, otherwise handle
756 struct GNUNET_FS_UnindexContext *
757 GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename,
760 struct GNUNET_FS_UnindexContext *ret;
761 struct GNUNET_FS_ProgressInfo pi;
764 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES))
766 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext));
768 ret->filename = GNUNET_strdup (filename);
769 ret->start_time = GNUNET_TIME_absolute_get ();
770 ret->file_size = size;
771 ret->client_info = cctx;
772 GNUNET_FS_unindex_sync_ (ret);
773 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
774 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
775 GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
777 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, filename,
779 &GNUNET_FS_unindex_process_hash_, ret);
780 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, ret);
786 * Clean up after completion of an unindex operation.
791 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
793 struct GNUNET_FS_ProgressInfo pi;
795 if (uc->dscan != NULL)
797 GNUNET_FS_directory_scan_abort (uc->dscan);
802 GNUNET_DATASTORE_cancel (uc->dqe);
807 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
810 if (uc->client != NULL)
812 GNUNET_CLIENT_disconnect (uc->client);
817 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
820 if (NULL != uc->ksk_uri)
822 GNUNET_FS_uri_destroy (uc->ksk_uri);
827 GNUNET_FS_tree_encoder_finish (uc->tc, NULL, NULL);
832 GNUNET_DISK_file_close (uc->fh);
835 GNUNET_FS_end_top (uc->h, uc->top);
836 if (uc->serialization != NULL)
838 GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
840 GNUNET_free (uc->serialization);
841 uc->serialization = NULL;
843 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED;
844 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
845 GNUNET_FS_unindex_make_status_ (&pi, uc,
847 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
848 GNUNET_break (NULL == uc->client_info);
849 GNUNET_free_non_null (uc->emsg);
850 GNUNET_free (uc->filename);
854 /* end of fs_unindex.c */