diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-22 18:34:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-22 18:34:29 +0000 |
commit | e483ac2a2c8eab6d5cc915c2f54ab2c27c469821 (patch) | |
tree | 0cdd2d9b3cc4fc62b085fb2f71103a100313448e /src/fs/fs_publish.c | |
parent | 3a04f1fdf2882b96608e164babcd34dbcb2ad777 (diff) | |
download | gnunet-e483ac2a2c8eab6d5cc915c2f54ab2c27c469821.tar.gz gnunet-e483ac2a2c8eab6d5cc915c2f54ab2c27c469821.zip |
LRN: two directory patches change the way "is_directory" is evaluated.
Now it must be GNUNET_YES for the execution flow to switch to a branch
where something is considered to be a directory.
The reason for that is that some functions might return GNUNET_SYSERR
when asked whether something is a directory or not. Checking this
value as "!= GNUNET_NO" will produce positive result, even though it's
not a directory.
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r-- | src/fs/fs_publish.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 315e3a157..1657e29e1 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -57,7 +57,7 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, | |||
57 | pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; | 57 | pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; |
58 | pi->value.publish.filename = p->filename; | 58 | pi->value.publish.filename = p->filename; |
59 | pi->value.publish.size = | 59 | pi->value.publish.size = |
60 | (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; | 60 | (p->is_directory == GNUNET_YES) ? p->data.dir.dir_size : p->data.file.file_size; |
61 | pi->value.publish.eta = | 61 | pi->value.publish.eta = |
62 | GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size); | 62 | GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size); |
63 | pi->value.publish.completed = offset; | 63 | pi->value.publish.completed = offset; |
@@ -132,7 +132,7 @@ ds_put_cont (void *cls, int success, | |||
132 | pi.value.publish.specifics.error.message = pc->fi_pos->emsg; | 132 | pi.value.publish.specifics.error.message = pc->fi_pos->emsg; |
133 | pc->fi_pos->client_info = | 133 | pc->fi_pos->client_info = |
134 | GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0); | 134 | GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0); |
135 | if ((pc->fi_pos->is_directory == GNUNET_NO) && | 135 | if ((pc->fi_pos->is_directory != GNUNET_YES) && |
136 | (pc->fi_pos->filename != NULL) && | 136 | (pc->fi_pos->filename != NULL) && |
137 | (pc->fi_pos->data.file.do_index == GNUNET_YES)) | 137 | (pc->fi_pos->data.file.do_index == GNUNET_YES)) |
138 | { | 138 | { |
@@ -191,7 +191,7 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p, | |||
191 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 191 | pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
192 | pi.value.publish.specifics.error.message = emsg; | 192 | pi.value.publish.specifics.error.message = emsg; |
193 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); | 193 | p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); |
194 | if ((p->is_directory == GNUNET_NO) && (p->filename != NULL) && | 194 | if ((p->is_directory != GNUNET_YES) && (p->filename != NULL) && |
195 | (p->data.file.do_index == GNUNET_YES)) | 195 | (p->data.file.do_index == GNUNET_YES)) |
196 | { | 196 | { |
197 | /* run unindex to clean up */ | 197 | /* run unindex to clean up */ |
@@ -347,7 +347,7 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) | |||
347 | const char *dd; | 347 | const char *dd; |
348 | 348 | ||
349 | p = pc->fi_pos; | 349 | p = pc->fi_pos; |
350 | if (p->is_directory) | 350 | if (p->is_directory == GNUNET_YES) |
351 | { | 351 | { |
352 | pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset); | 352 | pt_size = GNUNET_MIN (max, p->data.dir.dir_size - offset); |
353 | dd = p->data.dir.dir_data; | 353 | dd = p->data.dir.dir_data; |
@@ -451,7 +451,7 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | 453 | ||
454 | if ((!p->is_directory) && (GNUNET_YES == p->data.file.do_index) && | 454 | if ((p->is_directory != GNUNET_YES) && (GNUNET_YES == p->data.file.do_index) && |
455 | (type == GNUNET_BLOCK_TYPE_FS_DBLOCK)) | 455 | (type == GNUNET_BLOCK_TYPE_FS_DBLOCK)) |
456 | { | 456 | { |
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -462,7 +462,7 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
462 | odb.file_id = p->data.file.file_id; | 462 | odb.file_id = p->data.file.file_id; |
463 | GNUNET_assert (pc->qre == NULL); | 463 | GNUNET_assert (pc->qre == NULL); |
464 | pc->qre = | 464 | pc->qre = |
465 | GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid, | 465 | GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, |
466 | &chk->query, sizeof (struct OnDemandBlock), &odb, | 466 | &chk->query, sizeof (struct OnDemandBlock), &odb, |
467 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, | 467 | GNUNET_BLOCK_TYPE_FS_ONDEMAND, |
468 | p->bo.content_priority, p->bo.anonymity_level, | 468 | p->bo.content_priority, p->bo.anonymity_level, |
@@ -477,7 +477,7 @@ block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, | |||
477 | (unsigned int) block_size); | 477 | (unsigned int) block_size); |
478 | GNUNET_assert (pc->qre == NULL); | 478 | GNUNET_assert (pc->qre == NULL); |
479 | pc->qre = | 479 | pc->qre = |
480 | GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid, | 480 | GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, |
481 | &chk->query, block_size, block, type, | 481 | &chk->query, block_size, block, type, |
482 | p->bo.content_priority, p->bo.anonymity_level, | 482 | p->bo.content_priority, p->bo.anonymity_level, |
483 | p->bo.replication_level, p->bo.expiration_time, -2, | 483 | p->bo.replication_level, p->bo.expiration_time, -2, |
@@ -535,14 +535,14 @@ publish_content (struct GNUNET_FS_PublishContext *pc) | |||
535 | GNUNET_assert (p != NULL); | 535 | GNUNET_assert (p != NULL); |
536 | if (NULL == p->te) | 536 | if (NULL == p->te) |
537 | { | 537 | { |
538 | if (p->is_directory) | 538 | if (p->is_directory == GNUNET_YES) |
539 | { | 539 | { |
540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n"); | 540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating directory\n"); |
541 | db = GNUNET_FS_directory_builder_create (p->meta); | 541 | db = GNUNET_FS_directory_builder_create (p->meta); |
542 | dirpos = p->data.dir.entries; | 542 | dirpos = p->data.dir.entries; |
543 | while (NULL != dirpos) | 543 | while (NULL != dirpos) |
544 | { | 544 | { |
545 | if (dirpos->is_directory) | 545 | if (dirpos->is_directory == GNUNET_YES) |
546 | { | 546 | { |
547 | raw_data = dirpos->data.dir.dir_data; | 547 | raw_data = dirpos->data.dir.dir_data; |
548 | dirpos->data.dir.dir_data = NULL; | 548 | dirpos->data.dir.dir_data = NULL; |
@@ -578,7 +578,7 @@ publish_content (struct GNUNET_FS_PublishContext *pc) | |||
578 | &p->data.dir.dir_data); | 578 | &p->data.dir.dir_data); |
579 | GNUNET_FS_file_information_sync_ (p); | 579 | GNUNET_FS_file_information_sync_ (p); |
580 | } | 580 | } |
581 | size = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; | 581 | size = (p->is_directory == GNUNET_YES) ? p->data.dir.dir_size : p->data.file.file_size; |
582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n"); | 582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n"); |
583 | p->te = | 583 | p->te = |
584 | GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader, | 584 | GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader, |
@@ -783,7 +783,7 @@ GNUNET_FS_publish_main_ (void *cls, | |||
783 | return; | 783 | return; |
784 | } | 784 | } |
785 | /* find starting position */ | 785 | /* find starting position */ |
786 | while ((p->is_directory) && (NULL != p->data.dir.entries) && (NULL == p->emsg) | 786 | while ((p->is_directory == GNUNET_YES) && (NULL != p->data.dir.entries) && (NULL == p->emsg) |
787 | && (NULL == p->data.dir.entries->chk_uri)) | 787 | && (NULL == p->data.dir.entries->chk_uri)) |
788 | { | 788 | { |
789 | p = p->data.dir.entries; | 789 | p = p->data.dir.entries; |
@@ -847,7 +847,7 @@ GNUNET_FS_publish_main_ (void *cls, | |||
847 | } | 847 | } |
848 | return; | 848 | return; |
849 | } | 849 | } |
850 | if ((!p->is_directory) && (p->data.file.do_index)) | 850 | if ((p->is_directory != GNUNET_YES) && (p->data.file.do_index)) |
851 | { | 851 | { |
852 | if (NULL == p->filename) | 852 | if (NULL == p->filename) |
853 | { | 853 | { |