]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Reformat code that downloads metadata
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 31 Aug 2023 05:42:44 +0000 (05:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 31 Aug 2023 05:44:12 +0000 (05:44 +0000)
There are no functional changes here, but this is better to read.

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

index 64639450112412e95b963f4a82fc47078ad7257e..e2e80d63a5c9d4194206a3477f3b250facf89aec 100644 (file)
@@ -489,6 +489,14 @@ static int pakfire_repo_refresh_mirrorlist(struct pakfire_repo* repo, const int
 }
 
 static int pakfire_repo_download_metadata(struct pakfire_repo* repo, const char* path, int force) {
+       // Local repositories don't need to download metadata
+       if (pakfire_repo_is_local(repo))
+               return 0;
+
+       // Do nothing if running in offline mode
+       if (pakfire_has_flag(repo->pakfire, PAKFIRE_FLAGS_OFFLINE))
+               return 0;
+
        // Fetch refresh interval
        time_t refresh = repo->appdata->refresh;
 
@@ -523,12 +531,10 @@ static int pakfire_repo_refresh_metadata(struct pakfire_repo* repo, const int fo
        if (r)
                return r;
 
-       // Don't try to refresh the metadata for local repositories and if we are running offline
-       if (!pakfire_repo_is_local(repo) && !pakfire_has_flag(repo->pakfire, PAKFIRE_FLAGS_OFFLINE)) {
-               r = pakfire_repo_download_metadata(repo, path, force);
-               if (r)
-                       return r;
-       }
+       // Potentially download new metadata
+       r = pakfire_repo_download_metadata(repo, path, force);
+       if (r)
+               return r;
 
        // Parse metadata
        return pakfire_repo_read_metadata(repo, path);