aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-08 14:57:26 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-08 14:57:26 +0000
commit45729373b4b4ba643a90991503cac3da21a2796f (patch)
tree65b435c6ec7f6a1724e87a84ea33d9203d6a28de /src/fs/fs_publish.c
parent84e49f4f5a1252e8c9e88ccc91ee9b535fcf5fb2 (diff)
downloadgnunet-45729373b4b4ba643a90991503cac3da21a2796f.tar.gz
gnunet-45729373b4b4ba643a90991503cac3da21a2796f.zip
-fixing #2412
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r--src/fs/fs_publish.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 6c87f03d4..167a6dc07 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -959,41 +959,19 @@ fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi,
959 959
960 960
961/** 961/**
962 * Signal the FS's progress function that we are suspending 962 * Actually signal the FS's progress function that we are suspending
963 * an upload. 963 * an upload.
964 * 964 *
965 * @param cls closure (of type "struct GNUNET_FS_PublishContext*") 965 * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
966 * @param fi the entry in the publish-structure 966 * @param fi the entry in the publish-structure
967 * @param length length of the file or directory
968 * @param meta metadata for the file or directory (can be modified)
969 * @param uri pointer to the keywords that will be used for this entry (can be modified)
970 * @param bo block options
971 * @param do_index should we index?
972 * @param client_info pointer to client context set upon creation (can be modified)
973 * @return GNUNET_OK to continue (always)
974 */ 967 */
975static int 968static void
976fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi, 969suspend_operation (struct GNUNET_FS_FileInformation *fi,
977 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, 970 struct GNUNET_FS_PublishContext *pc)
978 struct GNUNET_FS_Uri **uri,
979 struct GNUNET_FS_BlockOptions *bo, int *do_index,
980 void **client_info)
981{ 971{
982 struct GNUNET_FS_PublishContext *pc = cls;
983 struct GNUNET_FS_ProgressInfo pi; 972 struct GNUNET_FS_ProgressInfo pi;
984 uint64_t off; 973 uint64_t off;
985 974
986 if (GNUNET_YES == pc->skip_next_fi_callback)
987 {
988 pc->skip_next_fi_callback = GNUNET_NO;
989 return GNUNET_OK;
990 }
991 if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
992 {
993 /* process entries in directory */
994 pc->skip_next_fi_callback = GNUNET_YES;
995 GNUNET_FS_file_information_inspect (fi, &fip_signal_suspend, pc);
996 }
997 if (NULL != pc->ksk_pc) 975 if (NULL != pc->ksk_pc)
998 { 976 {
999 GNUNET_FS_publish_ksk_cancel (pc->ksk_pc); 977 GNUNET_FS_publish_ksk_cancel (pc->ksk_pc);
@@ -1007,10 +985,9 @@ fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
1007 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending publish operation\n"); 985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending publish operation\n");
1008 GNUNET_free_non_null (fi->serialization); 986 GNUNET_free_non_null (fi->serialization);
1009 fi->serialization = NULL; 987 fi->serialization = NULL;
1010 off = (fi->chk_uri == NULL) ? 0 : length; 988 off = (fi->chk_uri == NULL) ? 0 : (fi->is_directory == GNUNET_YES) ? fi->data.dir.dir_size : fi->data.file.file_size;
1011 pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND; 989 pi.status = GNUNET_FS_STATUS_PUBLISH_SUSPEND;
1012 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off)); 990 GNUNET_break (NULL == GNUNET_FS_publish_make_status_ (&pi, pc, fi, off));
1013 *client_info = NULL;
1014 if (NULL != pc->qre) 991 if (NULL != pc->qre)
1015 { 992 {
1016 GNUNET_DATASTORE_cancel (pc->qre); 993 GNUNET_DATASTORE_cancel (pc->qre);
@@ -1022,6 +999,45 @@ fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
1022 pc->dsh = NULL; 999 pc->dsh = NULL;
1023 } 1000 }
1024 pc->rid = 0; 1001 pc->rid = 0;
1002}
1003
1004
1005/**
1006 * Signal the FS's progress function that we are suspending
1007 * an upload. Performs the recursion.
1008 *
1009 * @param cls closure (of type "struct GNUNET_FS_PublishContext*")
1010 * @param fi the entry in the publish-structure
1011 * @param length length of the file or directory
1012 * @param meta metadata for the file or directory (can be modified)
1013 * @param uri pointer to the keywords that will be used for this entry (can be modified)
1014 * @param bo block options
1015 * @param do_index should we index?
1016 * @param client_info pointer to client context set upon creation (can be modified)
1017 * @return GNUNET_OK to continue (always)
1018 */
1019static int
1020fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi,
1021 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta,
1022 struct GNUNET_FS_Uri **uri,
1023 struct GNUNET_FS_BlockOptions *bo, int *do_index,
1024 void **client_info)
1025{
1026 struct GNUNET_FS_PublishContext *pc = cls;
1027
1028 if (GNUNET_YES == pc->skip_next_fi_callback)
1029 {
1030 pc->skip_next_fi_callback = GNUNET_NO;
1031 return GNUNET_OK;
1032 }
1033 if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta))
1034 {
1035 /* process entries in directory */
1036 pc->skip_next_fi_callback = GNUNET_YES;
1037 GNUNET_FS_file_information_inspect (fi, &fip_signal_suspend, pc);
1038 }
1039 suspend_operation (fi, pc);
1040 *client_info = NULL;
1025 return GNUNET_OK; 1041 return GNUNET_OK;
1026} 1042}
1027 1043
@@ -1042,7 +1058,9 @@ GNUNET_FS_publish_signal_suspend_ (void *cls)
1042 GNUNET_SCHEDULER_cancel (pc->upload_task); 1058 GNUNET_SCHEDULER_cancel (pc->upload_task);
1043 pc->upload_task = GNUNET_SCHEDULER_NO_TASK; 1059 pc->upload_task = GNUNET_SCHEDULER_NO_TASK;
1044 } 1060 }
1061 pc->skip_next_fi_callback = GNUNET_YES;
1045 GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_suspend, pc); 1062 GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_suspend, pc);
1063 suspend_operation (pc->fi, pc);
1046 GNUNET_FS_end_top (pc->h, pc->top); 1064 GNUNET_FS_end_top (pc->h, pc->top);
1047 pc->top = NULL; 1065 pc->top = NULL;
1048 publish_cleanup (pc); 1066 publish_cleanup (pc);