]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Do not keep a downloader
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Apr 2021 09:35:33 +0000 (09:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 20 Apr 2021 09:35:33 +0000 (09:35 +0000)
There is no point in having a function to initialise a downloader which
basically has no settings.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index 876ff3f54fe5de77c607d6fdef0275d7af74ef7e..13bf96e7449a59a45c4f1fd28dec362a7945d4ba 100644 (file)
@@ -75,7 +75,6 @@ struct _PakfireRepo {
        int nrefs;
 
        struct pakfire_mirrorlist* mirrorlist;
-       struct pakfire_downloader* downloader;
 };
 
 int pakfire_repo_import(Pakfire pakfire, struct pakfire_config* config) {
@@ -146,16 +145,6 @@ Id pakfire_repo_add_solvable(PakfireRepo repo) {
        return repo_add_solvable(repo->repo);
 }
 
-static struct pakfire_downloader* pakfire_repo_downloader(PakfireRepo repo) {
-       if (!repo->downloader) {
-               int r = pakfire_downloader_create(&repo->downloader, repo->pakfire);
-               if (r)
-                       return NULL;
-       }
-
-       return pakfire_downloader_ref(repo->downloader);
-}
-
 struct pakfire_mirrorlist* pakfire_repo_get_mirrorlist(PakfireRepo repo) {
        if (!repo->mirrorlist) {
                // No cache path set
@@ -186,14 +175,12 @@ struct pakfire_mirrorlist* pakfire_repo_get_mirrorlist(PakfireRepo repo) {
 }
 
 static int pakfire_repo_retrieve(PakfireRepo repo, const char* url, const char* path) {
-       struct pakfire_downloader* downloader = NULL;
        struct pakfire_mirrorlist* mirrorlist = NULL;
-       int r = 1;
 
-       // Fetch downloader
-       downloader = pakfire_repo_downloader(repo);
-       if (!downloader)
-               goto ERROR;
+       struct pakfire_downloader* downloader;
+       int r = pakfire_downloader_create(&downloader, repo->pakfire);
+       if (r)
+               return r;
 
        // Fetch mirrorlist
        mirrorlist = pakfire_repo_get_mirrorlist(repo);
@@ -201,11 +188,9 @@ static int pakfire_repo_retrieve(PakfireRepo repo, const char* url, const char*
        // Retrieve the database file
        r = pakfire_downloader_retrieve(downloader, repo->appdata->baseurl, mirrorlist, url, path);
 
-ERROR:
-       if (downloader)
-               pakfire_downloader_unref(downloader);
        if (mirrorlist)
                pakfire_mirrorlist_unref(mirrorlist);
+       pakfire_downloader_unref(downloader);
 
        return r;
 }
@@ -355,8 +340,6 @@ static void pakfire_repo_free(PakfireRepo repo, const int free_repo) {
                repo_free(repo->repo, 0);
        }
 
-       if (repo->downloader)
-               pakfire_downloader_unref(repo->downloader);
        if (repo->mirrorlist)
                pakfire_mirrorlist_unref(repo->mirrorlist);
        pakfire_unref(repo->pakfire);