2 This file is part of GNUnet.
3 (C) 2003--2013 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"
34 #include "fs_publish_ublock.h"
38 * Function called by the tree encoder to obtain
39 * a block of plaintext data (for the lowest level
42 * @param cls our publishing context
43 * @param offset identifies which block to get
44 * @param max (maximum) number of bytes to get; returning
45 * fewer will also cause errors
46 * @param buf where to copy the plaintext buffer
47 * @param emsg location to store an error message (on error)
48 * @return number of bytes copied to buf, 0 on error
51 unindex_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
53 struct GNUNET_FS_UnindexContext *uc = cls;
56 pt_size = GNUNET_MIN (max, uc->file_size - offset);
57 if (offset != GNUNET_DISK_file_seek (uc->fh, offset, GNUNET_DISK_SEEK_SET))
59 *emsg = GNUNET_strdup (_("Failed to find given position in file"));
62 if (pt_size != GNUNET_DISK_file_read (uc->fh, buf, pt_size))
64 *emsg = GNUNET_strdup (_("Failed to read file"));
72 * Fill in all of the generic fields for
73 * an unindex event and call the callback.
75 * @param pi structure to fill in
76 * @param uc overall unindex context
77 * @param offset where we are in the file (for progress)
80 GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
81 struct GNUNET_FS_UnindexContext *uc,
84 pi->value.unindex.uc = uc;
85 pi->value.unindex.cctx = uc->client_info;
86 pi->value.unindex.filename = uc->filename;
87 pi->value.unindex.size = uc->file_size;
88 pi->value.unindex.eta =
89 GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size);
90 pi->value.unindex.duration =
91 GNUNET_TIME_absolute_get_duration (uc->start_time);
92 pi->value.unindex.completed = offset;
94 uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
99 * Function called with information about our
100 * progress in computing the tree encoding.
103 * @param offset where are we in the file
104 * @param pt_block plaintext of the currently processed block
105 * @param pt_size size of pt_block
106 * @param depth depth of the block in the tree, 0 for DBLOCK
109 unindex_progress (void *cls, uint64_t offset, const void *pt_block,
110 size_t pt_size, unsigned int depth)
112 struct GNUNET_FS_UnindexContext *uc = cls;
113 struct GNUNET_FS_ProgressInfo pi;
115 pi.status = GNUNET_FS_STATUS_UNINDEX_PROGRESS;
116 pi.value.unindex.specifics.progress.data = pt_block;
117 pi.value.unindex.specifics.progress.offset = offset;
118 pi.value.unindex.specifics.progress.data_len = pt_size;
119 pi.value.unindex.specifics.progress.depth = depth;
120 GNUNET_FS_unindex_make_status_ (&pi, uc, offset);
125 * We've encountered an error during
126 * unindexing. Signal the client.
128 * @param uc context for the failed unindexing operation
131 signal_unindex_error (struct GNUNET_FS_UnindexContext *uc)
133 struct GNUNET_FS_ProgressInfo pi;
135 pi.status = GNUNET_FS_STATUS_UNINDEX_ERROR;
136 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
137 pi.value.unindex.specifics.error.message = uc->emsg;
138 GNUNET_FS_unindex_make_status_ (&pi, uc, 0);
143 * Continuation called to notify client about result of the
144 * datastore removal operation.
147 * @param success GNUNET_SYSERR on failure
148 * @param min_expiration minimum expiration time required for content to be stored
149 * @param msg NULL on success, otherwise an error message
152 process_cont (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
154 struct GNUNET_FS_UnindexContext *uc = cls;
156 if (success == GNUNET_SYSERR)
158 uc->emsg = GNUNET_strdup (msg);
159 signal_unindex_error (uc);
162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
163 "Datastore REMOVE operation succeeded\n");
164 GNUNET_FS_tree_encoder_next (uc->tc);
169 * Function called asking for the current (encoded)
170 * block to be processed. After processing the
171 * client should either call "GNUNET_FS_tree_encode_next"
172 * or (on error) "GNUNET_FS_tree_encode_finish".
175 * @param chk content hash key for the block (key for lookup in the datastore)
176 * @param offset offset of the block
177 * @param depth depth of the block, 0 for DBLOCK
178 * @param type type of the block (IBLOCK or DBLOCK)
179 * @param block the (encrypted) block
180 * @param block_size size of block (in bytes)
183 unindex_process (void *cls, const struct ContentHashKey *chk, uint64_t offset,
184 unsigned int depth, enum GNUNET_BLOCK_Type type,
185 const void *block, uint16_t block_size)
187 struct GNUNET_FS_UnindexContext *uc = cls;
190 struct OnDemandBlock odb;
192 if (type != GNUNET_BLOCK_TYPE_FS_DBLOCK)
197 else /* on-demand encoded DBLOCK */
199 size = sizeof (struct OnDemandBlock);
200 odb.offset = GNUNET_htonll (offset);
201 odb.file_id = uc->file_id;
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
205 "Sending REMOVE request to DATASTORE service\n");
206 GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
207 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc);
213 * Function called with the response from the
214 * FS service to our unindexing request.
216 * @param cls closure, unindex context
217 * @param msg NULL on timeout, otherwise the response
220 process_fs_response (void *cls, const struct GNUNET_MessageHeader *msg)
222 struct GNUNET_FS_UnindexContext *uc = cls;
223 struct GNUNET_FS_ProgressInfo pi;
225 if (uc->client != NULL)
227 GNUNET_CLIENT_disconnect (uc->client);
230 if (uc->state != UNINDEX_STATE_FS_NOTIFY)
232 uc->state = UNINDEX_STATE_ERROR;
234 GNUNET_strdup (_("Unexpected time for a response from `fs' service."));
235 GNUNET_FS_unindex_sync_ (uc);
236 signal_unindex_error (uc);
241 uc->state = UNINDEX_STATE_ERROR;
242 uc->emsg = GNUNET_strdup (_("Timeout waiting for `fs' service."));
243 GNUNET_FS_unindex_sync_ (uc);
244 signal_unindex_error (uc);
247 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK)
249 uc->state = UNINDEX_STATE_ERROR;
250 uc->emsg = GNUNET_strdup (_("Invalid response from `fs' service."));
251 GNUNET_FS_unindex_sync_ (uc);
252 signal_unindex_error (uc);
255 uc->state = UNINDEX_STATE_COMPLETE;
256 pi.status = GNUNET_FS_STATUS_UNINDEX_COMPLETED;
257 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
258 GNUNET_FS_unindex_sync_ (uc);
259 GNUNET_FS_unindex_make_status_ (&pi, uc, uc->file_size);
264 * Function called when we are done with removing UBlocks.
265 * Disconnect from datastore and notify FS service about
268 * @param uc our unindexing context
271 unindex_finish (struct GNUNET_FS_UnindexContext *uc)
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, &emsg);
280 GNUNET_DISK_file_close (uc->fh);
282 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
284 uc->state = UNINDEX_STATE_FS_NOTIFY;
285 GNUNET_FS_unindex_sync_ (uc);
286 uc->client = GNUNET_CLIENT_connect ("fs", uc->h->cfg);
287 if (uc->client == NULL)
289 uc->state = UNINDEX_STATE_ERROR;
291 GNUNET_strdup (_("Failed to connect to FS service for unindexing."));
292 GNUNET_FS_unindex_sync_ (uc);
293 signal_unindex_error (uc);
296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
297 "Sending UNINDEX message to FS service\n");
298 req.header.size = htons (sizeof (struct UnindexMessage));
299 req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
301 req.file_id = uc->file_id;
302 GNUNET_break (GNUNET_OK ==
303 GNUNET_CLIENT_transmit_and_get_response (uc->client,
305 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
307 &process_fs_response,
314 * Function called by the directory scanner as we extract keywords
315 * that we will need to remove UBlocks.
317 * @param cls the 'struct GNUNET_FS_UnindexContext *'
318 * @param filename which file we are making progress on
319 * @param is_directory GNUNET_YES if this is a directory,
320 * GNUNET_NO if this is a file
321 * GNUNET_SYSERR if it is neither (or unknown)
322 * @param reason kind of progress we are making
325 unindex_directory_scan_cb (void *cls,
326 const char *filename,
328 enum GNUNET_FS_DirScannerProgressUpdateReason reason)
330 struct GNUNET_FS_UnindexContext *uc = cls;
331 static struct GNUNET_FS_ShareTreeItem * directory_scan_result;
335 case GNUNET_FS_DIRSCANNER_FINISHED:
336 directory_scan_result = GNUNET_FS_directory_scan_get_result (uc->dscan);
338 if (NULL != directory_scan_result->ksk_uri)
340 uc->ksk_uri = GNUNET_FS_uri_dup (directory_scan_result->ksk_uri);
341 uc->state = UNINDEX_STATE_DS_REMOVE_KBLOCKS;
342 GNUNET_FS_unindex_sync_ (uc);
343 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
347 uc->emsg = GNUNET_strdup (_("Failed to get KSKs from directory scan."));
348 GNUNET_FS_unindex_sync_ (uc);
351 GNUNET_FS_share_tree_free (directory_scan_result);
353 case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
354 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
355 _("Internal error scanning `%s'.\n"),
357 GNUNET_FS_directory_scan_abort (uc->dscan);
359 uc->emsg = GNUNET_strdup (_("Failed to get KSKs from directory scan."));
360 GNUNET_FS_unindex_sync_ (uc);
370 * If necessary, connect to the datastore and remove the UBlocks.
372 * @param uc context for the unindex operation.
375 GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc)
380 GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS", &ex))
382 uc->dscan = GNUNET_FS_directory_scan_start (uc->filename,
384 &unindex_directory_scan_cb,
386 GNUNET_free_non_null (ex);
391 * Continuation called to notify client about result of the remove
392 * operation for the UBlock.
394 * @param cls the 'struct GNUNET_FS_UnindexContext *'
395 * @param success GNUNET_SYSERR on failure (including timeout/queue drop)
396 * GNUNET_NO if content was already there
397 * GNUNET_YES (or other positive value) on success
398 * @param min_expiration minimum expiration time required for 0-priority content to be stored
399 * by the datacache at this time, zero for unknown, forever if we have no
400 * space for 0-priority content
401 * @param msg NULL on success, otherwise an error message
404 continue_after_remove (void *cls,
406 struct GNUNET_TIME_Absolute min_expiration,
409 struct GNUNET_FS_UnindexContext *uc = cls;
412 if (success != GNUNET_YES)
413 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
414 _("Failed to remove UBlock: %s\n"),
417 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
422 * Function called from datastore with result from us looking for
423 * a UBlock. There are four cases:
424 * 1) no result, means we move on to the next keyword
425 * 2) UID is the same as the first UID, means we move on to next keyword
426 * 3) UBlock for a different CHK, means we keep looking for more
427 * 4) UBlock is for our CHK, means we remove the block and then move
428 * on to the next keyword
430 * @param cls the 'struct GNUNET_FS_UnindexContext *'
431 * @param key key for the content
432 * @param size number of bytes in data
433 * @param data content stored
434 * @param type type of the content
435 * @param priority priority of the content
436 * @param anonymity anonymity-level for the content
437 * @param expiration expiration time for the content
438 * @param uid unique identifier for the datum;
439 * maybe 0 if no unique identifier is available
442 process_kblock_for_unindex (void *cls,
443 const struct GNUNET_HashCode *key,
444 size_t size, const void *data,
445 enum GNUNET_BLOCK_Type type,
448 struct GNUNET_TIME_Absolute
449 expiration, uint64_t uid)
451 struct GNUNET_FS_UnindexContext *uc = cls;
452 const struct UBlock *ub;
453 struct GNUNET_FS_Uri *chk_uri;
454 struct GNUNET_HashCode query;
461 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
464 if (0 == uc->first_uid)
466 /* remember UID of first result to detect cycles */
469 else if (uid == uc->first_uid)
471 /* no more additional results */
473 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
476 GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type);
477 if (size < sizeof (struct UBlock))
483 GNUNET_CRYPTO_hash (&ub->verification_key,
484 sizeof (ub->verification_key),
486 if (0 != memcmp (&query, key, sizeof (struct GNUNET_HashCode)))
488 /* result does not match our keyword, skip */
492 char pt[size - sizeof (struct UBlock)];
493 struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
496 GNUNET_CRYPTO_ecdsa_key_get_public (GNUNET_CRYPTO_ecdsa_key_get_anonymous (),
498 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
499 GNUNET_FS_ublock_decrypt_ (&ub[1], size - sizeof (struct UBlock),
503 if (NULL == memchr (&pt[1], 0, sizeof (pt) - 1))
505 GNUNET_break_op (0); /* malformed UBlock */
508 chk_uri = GNUNET_FS_uri_parse (&pt[1], NULL);
511 GNUNET_break_op (0); /* malformed UBlock */
515 if (0 != memcmp (&uc->chk,
516 &chk_uri->data.chk.chk,
517 sizeof (struct ContentHashKey)))
519 /* different CHK, ignore */
520 GNUNET_FS_uri_destroy (chk_uri);
523 GNUNET_FS_uri_destroy (chk_uri);
525 uc->dqe = GNUNET_DATASTORE_remove (uc->dsh,
527 0 /* priority */, 1 /* queue size */,
528 GNUNET_TIME_UNIT_FOREVER_REL,
529 &continue_after_remove,
533 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
536 GNUNET_BLOCK_TYPE_FS_UBLOCK,
537 0 /* priority */, 1 /* queue size */,
538 GNUNET_TIME_UNIT_FOREVER_REL,
539 &process_kblock_for_unindex,
545 * If necessary, connect to the datastore and remove the KBlocks.
547 * @param uc context for the unindex operation.
550 GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
553 const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
554 struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
555 struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
558 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
561 uc->state = UNINDEX_STATE_ERROR;
562 uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service."));
563 GNUNET_FS_unindex_sync_ (uc);
564 signal_unindex_error (uc);
567 if ( (NULL == uc->ksk_uri) ||
568 (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount) )
573 anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
574 GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
575 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
576 GNUNET_CRYPTO_ecdsa_public_key_derive (&anon_pub,
580 GNUNET_CRYPTO_hash (&dpub,
584 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
587 GNUNET_BLOCK_TYPE_FS_UBLOCK,
588 0 /* priority */, 1 /* queue size */,
589 GNUNET_TIME_UNIT_FOREVER_REL,
590 &process_kblock_for_unindex,
596 * Function called when the tree encoder has
597 * processed all blocks. Clean up.
599 * @param cls our unindexing context
603 unindex_extract_keywords (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
605 struct GNUNET_FS_UnindexContext *uc = cls;
607 uc->state = UNINDEX_STATE_EXTRACT_KEYWORDS;
608 GNUNET_FS_unindex_sync_ (uc);
609 GNUNET_FS_unindex_do_extract_keywords_ (uc);
614 * Connect to the datastore and remove the blocks.
616 * @param uc context for the unindex operation.
619 GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc)
622 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
625 uc->state = UNINDEX_STATE_ERROR;
626 uc->emsg = GNUNET_strdup (_("Failed to connect to `datastore' service."));
627 GNUNET_FS_unindex_sync_ (uc);
628 signal_unindex_error (uc);
632 GNUNET_DISK_file_open (uc->filename, GNUNET_DISK_OPEN_READ,
633 GNUNET_DISK_PERM_NONE);
636 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
638 uc->state = UNINDEX_STATE_ERROR;
639 uc->emsg = GNUNET_strdup (_("Failed to open file for unindexing."));
640 GNUNET_FS_unindex_sync_ (uc);
641 signal_unindex_error (uc);
645 GNUNET_FS_tree_encoder_create (uc->h, uc->file_size, uc, &unindex_reader,
646 &unindex_process, &unindex_progress,
647 &unindex_extract_keywords);
648 GNUNET_FS_tree_encoder_next (uc->tc);
653 * Function called once the hash of the file
654 * that is being unindexed has been computed.
656 * @param cls closure, unindex context
657 * @param file_id computed hash, NULL on error
660 GNUNET_FS_unindex_process_hash_ (void *cls, const struct GNUNET_HashCode * file_id)
662 struct GNUNET_FS_UnindexContext *uc = cls;
665 if (uc->state != UNINDEX_STATE_HASHING)
667 GNUNET_FS_unindex_stop (uc);
672 uc->state = UNINDEX_STATE_ERROR;
673 uc->emsg = GNUNET_strdup (_("Failed to compute hash of file."));
674 GNUNET_FS_unindex_sync_ (uc);
675 signal_unindex_error (uc);
678 uc->file_id = *file_id;
679 uc->state = UNINDEX_STATE_DS_REMOVE;
680 GNUNET_FS_unindex_sync_ (uc);
681 GNUNET_FS_unindex_do_remove_ (uc);
686 * Create SUSPEND event for the given unindex operation
687 * and then clean up our state (without stop signal).
689 * @param cls the `struct GNUNET_FS_UnindexContext` to signal for
692 GNUNET_FS_unindex_signal_suspend_ (void *cls)
694 struct GNUNET_FS_UnindexContext *uc = cls;
695 struct GNUNET_FS_ProgressInfo pi;
697 /* FIXME: lots of duplication with unindex_stop here! */
698 if (uc->dscan != NULL)
700 GNUNET_FS_directory_scan_abort (uc->dscan);
705 GNUNET_DATASTORE_cancel (uc->dqe);
710 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
713 if (NULL != uc->ksk_uri)
715 GNUNET_FS_uri_destroy (uc->ksk_uri);
718 if (uc->client != NULL)
720 GNUNET_CLIENT_disconnect (uc->client);
725 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
730 GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
735 GNUNET_DISK_file_close (uc->fh);
738 GNUNET_FS_end_top (uc->h, uc->top);
739 pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
740 GNUNET_FS_unindex_make_status_ (&pi, uc,
742 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
743 GNUNET_break (NULL == uc->client_info);
744 GNUNET_free (uc->filename);
745 GNUNET_free_non_null (uc->serialization);
746 GNUNET_free_non_null (uc->emsg);
754 * @param h handle to the file sharing subsystem
755 * @param filename file to unindex
756 * @param cctx initial value for the client context
757 * @return NULL on error, otherwise handle
759 struct GNUNET_FS_UnindexContext *
760 GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
761 const char *filename,
764 struct GNUNET_FS_UnindexContext *ret;
765 struct GNUNET_FS_ProgressInfo pi;
768 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES))
770 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext));
772 ret->filename = GNUNET_strdup (filename);
773 ret->start_time = GNUNET_TIME_absolute_get ();
774 ret->file_size = size;
775 ret->client_info = cctx;
776 GNUNET_FS_unindex_sync_ (ret);
777 pi.status = GNUNET_FS_STATUS_UNINDEX_START;
778 pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
779 GNUNET_FS_unindex_make_status_ (&pi, ret, 0);
781 GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, filename,
783 &GNUNET_FS_unindex_process_hash_, ret);
784 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, ret);
790 * Clean up after completion of an unindex operation.
795 GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc)
797 struct GNUNET_FS_ProgressInfo pi;
799 if (uc->dscan != NULL)
801 GNUNET_FS_directory_scan_abort (uc->dscan);
806 GNUNET_DATASTORE_cancel (uc->dqe);
811 GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
814 if (uc->client != NULL)
816 GNUNET_CLIENT_disconnect (uc->client);
821 GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
824 if (NULL != uc->ksk_uri)
826 GNUNET_FS_uri_destroy (uc->ksk_uri);
831 GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
836 GNUNET_DISK_file_close (uc->fh);
839 GNUNET_FS_end_top (uc->h, uc->top);
840 if (uc->serialization != NULL)
842 GNUNET_FS_remove_sync_file_ (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX,
844 GNUNET_free (uc->serialization);
845 uc->serialization = NULL;
847 pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED;
848 pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
849 GNUNET_FS_unindex_make_status_ (&pi, uc,
851 UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
852 GNUNET_break (NULL == uc->client_info);
853 GNUNET_free_non_null (uc->emsg);
854 GNUNET_free (uc->filename);
858 /* end of fs_unindex.c */