]> git.ipfire.org Git - pakfire.git/commitdiff
stripper: Ignore if source files don't exist
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 Dec 2024 14:54:10 +0000 (14:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 Dec 2024 14:54:10 +0000 (14:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/stripper.c

index 631151c2ab78dff443c26dc8914ff949c56da389..f93025ee6e07efa449a9ad4ac66c16f3b7ec9c56 100644 (file)
@@ -231,6 +231,29 @@ static int pakfire_stripper_copy_source_file(
        if (r < 0)
                goto ERROR;
 
+       // Open the source file
+       src = fopen(srcpath, "r");
+       if (!src) {
+               switch (errno) {
+                       // If the source file does not exist, we cannot copy anything
+                       case ENOENT:
+                               goto ERROR;
+
+                       default:
+                               ERROR(stripper->ctx, "Could not open %s: %m\n", filename);
+                               r = -errno;
+                               goto ERROR;
+               }
+       }
+
+       // Stat the source file
+       r = fstat(fileno(src), &st);
+       if (r < 0) {
+               ERROR(stripper->ctx, "Could not stat %s: %m\n", filename);
+               r = -errno;
+               goto ERROR;
+       }
+
        // Create all directories
        r = pakfire_mkparentdir(dstpath, 0755);
        if (r < 0)
@@ -251,22 +274,6 @@ static int pakfire_stripper_copy_source_file(
                }
        }
 
-       // Open the source file
-       src = fopen(srcpath, "r");
-       if (!src) {
-               ERROR(stripper->ctx, "Could not open %s: %m\n", filename);
-               r = -errno;
-               goto ERROR;
-       }
-
-       // Stat the source file
-       r = fstat(fileno(src), &st);
-       if (r < 0) {
-               ERROR(stripper->ctx, "Could not stat %s: %m\n", filename);
-               r = -errno;
-               goto ERROR;
-       }
-
        // Copy all content
        ssize_t bytes_written = sendfile(fileno(dst), fileno(src), 0, st.st_size);
        if (bytes_written < st.st_size) {