]> git.ipfire.org Git - pakfire.git/commitdiff
filelist: Don't fail scan when the path does not exist
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 7 Sep 2023 14:22:20 +0000 (14:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 7 Sep 2023 14:22:20 +0000 (14:22 +0000)
I believe this is what we mostly want.

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

index f63ddafaf989bab1a284db8af9b8f5f0424fc4f6..d44b7964aad55fc2fead0187a01736a25a861a83 100644 (file)
@@ -288,6 +288,7 @@ static int pakfire_filelist_scan_filter(struct archive* archive, void* p,
 
 int pakfire_filelist_scan(struct pakfire_filelist* list, const char* root,
                const char** includes, const char** excludes, int flags) {
+       struct archive* reader = NULL;
        struct pakfire_file* file = NULL;
        struct archive_entry* entry = NULL;
        struct pakfire_filelist_matches matches = {
@@ -320,8 +321,15 @@ int pakfire_filelist_scan(struct pakfire_filelist* list, const char* root,
                        DEBUG(list->pakfire, "    %s\n", *exclude);
        }
 
+       // Check if the path exists
+       if (!pakfire_path_exists(root)) {
+               DEBUG(list->pakfire, "Path to scan (%s) does not exist\n", root);
+               r = 0;
+               goto ERROR;
+       }
+
        // Create a new disk reader
-       struct archive* reader = pakfire_make_archive_disk_reader(list->pakfire, 1);
+       reader = pakfire_make_archive_disk_reader(list->pakfire, 1);
        if (!reader)
                goto ERROR;
 
@@ -380,7 +388,8 @@ int pakfire_filelist_scan(struct pakfire_filelist* list, const char* root,
        }
 
 ERROR:
-       archive_read_free(reader);
+       if (reader)
+               archive_read_free(reader);
 
        return r;
 }
index d72a8d7b33e5027d7cd7e69f1a73ac571286f40f..982e51ca428815e783f321278ece4cb0cff80f3e 100644 (file)
@@ -81,10 +81,6 @@ 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 9bf4c92a449718b9fb3cd42c0d7c7a39de210c04..e2e80d63a5c9d4194206a3477f3b250facf89aec 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, PAKFIRE_REPO_SCAN_IGNORE_NOENT);
+                                       return pakfire_repo_scan(repo, 0);
                                }
                                break;
                }
@@ -1317,12 +1317,6 @@ 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)