diff options
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r-- | src/gnunet_chat_lib.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index b273441..f4e8d42 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -759,6 +759,11 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, | |||
759 | if (GNUNET_OK != util_hash_file(path, &hash)) | 759 | if (GNUNET_OK != util_hash_file(path, &hash)) |
760 | return NULL; | 760 | return NULL; |
761 | 761 | ||
762 | const char *directory = handle_get_directory(context->handle); | ||
763 | |||
764 | if (!directory) | ||
765 | return NULL; | ||
766 | |||
762 | struct GNUNET_CHAT_File *file = GNUNET_CONTAINER_multihashmap_get( | 767 | struct GNUNET_CHAT_File *file = GNUNET_CONTAINER_multihashmap_get( |
763 | context->handle->files, | 768 | context->handle->files, |
764 | &hash | 769 | &hash |
@@ -766,7 +771,7 @@ GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, | |||
766 | 771 | ||
767 | char *filename; | 772 | char *filename; |
768 | util_get_filename ( | 773 | util_get_filename ( |
769 | context->handle->directory, "files", &hash, &filename | 774 | directory, "files", &hash, &filename |
770 | ); | 775 | ); |
771 | 776 | ||
772 | if (file) | 777 | if (file) |
@@ -1128,9 +1133,14 @@ GNUNET_CHAT_file_get_local_size (const struct GNUNET_CHAT_File *file) | |||
1128 | if (!file) | 1133 | if (!file) |
1129 | return 0; | 1134 | return 0; |
1130 | 1135 | ||
1136 | const char *directory = handle_get_directory(file->handle); | ||
1137 | |||
1138 | if (!directory) | ||
1139 | return 0; | ||
1140 | |||
1131 | char *filename; | 1141 | char *filename; |
1132 | util_get_filename ( | 1142 | util_get_filename ( |
1133 | file->handle->directory, "files", &(file->hash), &filename | 1143 | directory, "files", &(file->hash), &filename |
1134 | ); | 1144 | ); |
1135 | 1145 | ||
1136 | uint64_t size; | 1146 | uint64_t size; |
@@ -1161,9 +1171,14 @@ GNUNET_CHAT_file_open_preview (struct GNUNET_CHAT_File *file) | |||
1161 | if (file->preview) | 1171 | if (file->preview) |
1162 | return file->preview; | 1172 | return file->preview; |
1163 | 1173 | ||
1174 | const char *directory = handle_get_directory(file->handle); | ||
1175 | |||
1176 | if (!directory) | ||
1177 | return NULL; | ||
1178 | |||
1164 | char *filename; | 1179 | char *filename; |
1165 | util_get_filename ( | 1180 | util_get_filename ( |
1166 | file->handle->directory, "files", &(file->hash), &filename | 1181 | directory, "files", &(file->hash), &filename |
1167 | ); | 1182 | ); |
1168 | 1183 | ||
1169 | if (GNUNET_YES != GNUNET_DISK_file_test(filename)) | 1184 | if (GNUNET_YES != GNUNET_DISK_file_test(filename)) |
@@ -1251,11 +1266,16 @@ GNUNET_CHAT_file_start_download (struct GNUNET_CHAT_File *file, | |||
1251 | return GNUNET_OK; | 1266 | return GNUNET_OK; |
1252 | } | 1267 | } |
1253 | 1268 | ||
1269 | const char *directory = handle_get_directory(file->handle); | ||
1270 | |||
1271 | if (!directory) | ||
1272 | return GNUNET_SYSERR; | ||
1273 | |||
1254 | const uint64_t size = GNUNET_FS_uri_chk_get_file_size(file->uri); | 1274 | const uint64_t size = GNUNET_FS_uri_chk_get_file_size(file->uri); |
1255 | 1275 | ||
1256 | char *filename; | 1276 | char *filename; |
1257 | util_get_filename ( | 1277 | util_get_filename ( |
1258 | file->handle->directory, "files", &(file->hash), &filename | 1278 | directory, "files", &(file->hash), &filename |
1259 | ); | 1279 | ); |
1260 | 1280 | ||
1261 | uint64_t offset; | 1281 | uint64_t offset; |
@@ -1362,9 +1382,14 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, | |||
1362 | if (file->unindex) | 1382 | if (file->unindex) |
1363 | return GNUNET_OK; | 1383 | return GNUNET_OK; |
1364 | 1384 | ||
1385 | const char *directory = handle_get_directory(file->handle); | ||
1386 | |||
1387 | if (!directory) | ||
1388 | return GNUNET_SYSERR; | ||
1389 | |||
1365 | char *filename; | 1390 | char *filename; |
1366 | util_get_filename ( | 1391 | util_get_filename ( |
1367 | file->handle->directory, "files", &(file->hash), &filename | 1392 | directory, "files", &(file->hash), &filename |
1368 | ); | 1393 | ); |
1369 | 1394 | ||
1370 | file->unindex = GNUNET_FS_unindex_start( | 1395 | file->unindex = GNUNET_FS_unindex_start( |