* Recursively download all bundles advertised at the given URI * to files. If the file is a bundle, then add it to the given * 'list'. Otherwise, expect a bundle list and recurse on the * URIs in that list according to the list mode (ANY or ALL). */
| 754 | * URIs in that list according to the list mode (ANY or ALL). |
| 755 | */ |
| 756 | static int fetch_bundle_uri_internal(struct repository *r, |
| 757 | struct remote_bundle_info *bundle, |
| 758 | int depth, |
| 759 | struct bundle_list *list) |
| 760 | { |
| 761 | int result = 0; |
| 762 | struct remote_bundle_info *bcopy; |
| 763 | |
| 764 | if (depth >= max_bundle_uri_depth) { |
| 765 | warning(_("exceeded bundle URI recursion limit (%d)"), |
| 766 | max_bundle_uri_depth); |
| 767 | return -1; |
| 768 | } |
| 769 | |
| 770 | if (!bundle->uri) { |
| 771 | error(_("bundle '%s' has no uri"), |
| 772 | bundle->id ? bundle->id : "<unknown>"); |
| 773 | return -1; |
| 774 | } |
| 775 | |
| 776 | if (!bundle->file && |
| 777 | !(bundle->file = find_temp_filename())) { |
| 778 | result = -1; |
| 779 | goto cleanup; |
| 780 | } |
| 781 | |
| 782 | if ((result = copy_uri_to_file(bundle->file, bundle->uri))) { |
| 783 | warning(_("failed to download bundle from URI '%s'"), bundle->uri); |
| 784 | goto cleanup; |
| 785 | } |
| 786 | |
| 787 | if ((result = !is_bundle(bundle->file, 1))) { |
| 788 | result = fetch_bundle_list_in_config_format( |
| 789 | r, list, bundle, depth); |
| 790 | if (result) |
| 791 | warning(_("file at URI '%s' is not a bundle or bundle list"), |
| 792 | bundle->uri); |
| 793 | goto cleanup; |
| 794 | } |
| 795 | |
| 796 | /* Copy the bundle and insert it into the global list. */ |
| 797 | CALLOC_ARRAY(bcopy, 1); |
| 798 | bcopy->id = xstrdup(bundle->id); |
| 799 | bcopy->file = xstrdup(bundle->file); |
| 800 | hashmap_entry_init(&bcopy->ent, strhash(bcopy->id)); |
| 801 | hashmap_add(&list->bundles, &bcopy->ent); |
| 802 | |
| 803 | cleanup: |
| 804 | if (result && bundle->file) |
| 805 | unlink(bundle->file); |
| 806 | return result; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * This loop iterator breaks the loop with nonzero return code on the |
no test coverage detected