]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Ignore if local repositories don't exist when scanning
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Sep 2023 16:11:21 +0000 (16:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Sep 2023 16:11:21 +0000 (16:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/repo.h
src/libpakfire/repo.c

index 982e51ca428815e783f321278ece4cb0cff80f3e..d72a8d7b33e5027d7cd7e69f1a73ac571286f40f 100644 (file)
@@ -81,6 +81,10 @@ int pakfire_repo_clean(struct pakfire_repo* repo, int flags);
 
 // Scan
 
+enum pakfire_repo_scan_flags {
+       PAKFIRE_REPO_SCAN_IGNORE_NOENT = (1 << 0),
+};
+
 int pakfire_repo_scan(struct pakfire_repo* repo, int flags);
 
 // Refresh
index e2e80d63a5c9d4194206a3477f3b250facf89aec..9bf4c92a449718b9fb3cd42c0d7c7a39de210c04 100644 (file)
@@ -407,7 +407,7 @@ static int pakfire_repo_read_metadata(struct pakfire_repo* repo, const char* pat
                                        DEBUG(repo->pakfire, "No metadata available on local repository."
                                                " Falling back to scan...\n");
 
-                                       return pakfire_repo_scan(repo, 0);
+                                       return pakfire_repo_scan(repo, PAKFIRE_REPO_SCAN_IGNORE_NOENT);
                                }
                                break;
                }
@@ -1317,6 +1317,12 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
                return 1;
        }
 
+       // Check if path exists
+       if (!pakfire_path_exists(path)) {
+               if (flags & PAKFIRE_REPO_SCAN_IGNORE_NOENT)
+                       return 0;
+       }
+
        // Create a new filelist
        r = pakfire_filelist_create(&filelist, repo->pakfire);
        if (r)