diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-28 09:55:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-28 09:55:08 +0000 |
commit | 8bde78602f8be7df9f524c45fb2997fc9412f6fc (patch) | |
tree | 0534c7b4f38e550f6ec0ff6105b1b8bdd6e2e46d /src/fs/gnunet-helper-fs-publish.c | |
parent | 047de959d99fea44ded0a93089d71930f3f5258e (diff) | |
download | gnunet-8bde78602f8be7df9f524c45fb2997fc9412f6fc.tar.gz gnunet-8bde78602f8be7df9f524c45fb2997fc9412f6fc.zip |
-fixing #2365
Diffstat (limited to 'src/fs/gnunet-helper-fs-publish.c')
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 533d5d51a..86b02492d 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -210,7 +210,8 @@ write_message (uint16_t message_type, | |||
210 | * the scan. Does NOT yet add any metadata. | 210 | * the scan. Does NOT yet add any metadata. |
211 | * | 211 | * |
212 | * @param filename file or directory to scan | 212 | * @param filename file or directory to scan |
213 | * @param dst where to store the resulting share tree item | 213 | * @param dst where to store the resulting share tree item; |
214 | * NULL is stored in 'dst' upon recoverable errors (GNUNET_OK is returned) | ||
214 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 215 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
215 | */ | 216 | */ |
216 | static int | 217 | static int |
@@ -258,6 +259,8 @@ scan_callback (void *cls, | |||
258 | rc->stop = GNUNET_YES; | 259 | rc->stop = GNUNET_YES; |
259 | return GNUNET_SYSERR; | 260 | return GNUNET_SYSERR; |
260 | } | 261 | } |
262 | if (NULL == chld) | ||
263 | return GNUNET_OK; | ||
261 | chld->parent = rc->parent; | 264 | chld->parent = rc->parent; |
262 | GNUNET_CONTAINER_DLL_insert (rc->parent->children_head, | 265 | GNUNET_CONTAINER_DLL_insert (rc->parent->children_head, |
263 | rc->parent->children_tail, | 266 | rc->parent->children_tail, |
@@ -272,7 +275,8 @@ scan_callback (void *cls, | |||
272 | * the scan. Does NOT yet add any metadata. | 275 | * the scan. Does NOT yet add any metadata. |
273 | * | 276 | * |
274 | * @param filename file or directory to scan | 277 | * @param filename file or directory to scan |
275 | * @param dst where to store the resulting share tree item | 278 | * @param dst where to store the resulting share tree item; |
279 | * NULL is stored in 'dst' upon recoverable errors (GNUNET_OK is returned) | ||
276 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 280 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
277 | */ | 281 | */ |
278 | static int | 282 | static int |
@@ -293,6 +297,8 @@ preprocess_file (const char *filename, | |||
293 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE, | 297 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE, |
294 | filename, strlen (filename) + 1)) | 298 | filename, strlen (filename) + 1)) |
295 | return GNUNET_SYSERR; | 299 | return GNUNET_SYSERR; |
300 | /* recoverable error, store 'NULL' in *dst */ | ||
301 | *dst = NULL; | ||
296 | return GNUNET_OK; | 302 | return GNUNET_OK; |
297 | } | 303 | } |
298 | 304 | ||
@@ -307,7 +313,7 @@ preprocess_file (const char *filename, | |||
307 | item->filename = GNUNET_strdup (filename); | 313 | item->filename = GNUNET_strdup (filename); |
308 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; | 314 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; |
309 | item->file_size = fsize; | 315 | item->file_size = fsize; |
310 | if (item->is_directory == GNUNET_YES) | 316 | if (GNUNET_YES == item->is_directory) |
311 | { | 317 | { |
312 | struct RecursionContext rc; | 318 | struct RecursionContext rc; |
313 | 319 | ||
@@ -316,7 +322,7 @@ preprocess_file (const char *filename, | |||
316 | GNUNET_DISK_directory_scan (filename, | 322 | GNUNET_DISK_directory_scan (filename, |
317 | &scan_callback, | 323 | &scan_callback, |
318 | &rc); | 324 | &rc); |
319 | if ( (rc.stop == GNUNET_YES) || | 325 | if ( (GNUNET_YES == rc.stop) || |
320 | (GNUNET_OK != | 326 | (GNUNET_OK != |
321 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY, | 327 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY, |
322 | "..", 3)) ) | 328 | "..", 3)) ) |
@@ -421,7 +427,7 @@ int main(int argc, | |||
421 | #endif | 427 | #endif |
422 | 428 | ||
423 | /* parse command line */ | 429 | /* parse command line */ |
424 | if ( (argc != 3) && (argc != 2) ) | 430 | if ( (3 != argc) && (2 != argc) ) |
425 | { | 431 | { |
426 | FPRINTF (stderr, | 432 | FPRINTF (stderr, |
427 | "%s", | 433 | "%s", |
@@ -430,7 +436,7 @@ int main(int argc, | |||
430 | } | 436 | } |
431 | filename_expanded = argv[1]; | 437 | filename_expanded = argv[1]; |
432 | ex = argv[2]; | 438 | ex = argv[2]; |
433 | if ( (ex == NULL) || | 439 | if ( (NULL == ex) || |
434 | (0 != strcmp (ex, "-")) ) | 440 | (0 != strcmp (ex, "-")) ) |
435 | { | 441 | { |
436 | plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); | 442 | plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); |
@@ -451,14 +457,17 @@ int main(int argc, | |||
451 | if (GNUNET_OK != | 457 | if (GNUNET_OK != |
452 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) | 458 | write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, NULL, 0)) |
453 | return 3; | 459 | return 3; |
454 | if (GNUNET_OK != | 460 | if (NULL != root) |
455 | extract_files (root)) | ||
456 | { | 461 | { |
457 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); | 462 | if (GNUNET_OK != |
463 | extract_files (root)) | ||
464 | { | ||
465 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, NULL, 0); | ||
466 | free_tree (root); | ||
467 | return 4; | ||
468 | } | ||
458 | free_tree (root); | 469 | free_tree (root); |
459 | return 4; | ||
460 | } | 470 | } |
461 | free_tree (root); | ||
462 | /* enable "clean" shutdown by telling parent that we are done */ | 471 | /* enable "clean" shutdown by telling parent that we are done */ |
463 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); | 472 | (void) write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, NULL, 0); |
464 | if (NULL != plugins) | 473 | if (NULL != plugins) |