From: Michael Tremer Date: Tue, 9 Aug 2022 13:16:00 +0000 (+0000) Subject: pakfire: Fix return code of pakfire_copy on error X-Git-Tag: 0.9.28~549 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abf75d372bd1f71676e018f9e766d3b930febdec;p=pakfire.git pakfire: Fix return code of pakfire_copy on error Before, the function count return zero even though an error occured. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 345be179e..39c94a96f 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1011,6 +1011,8 @@ static int pakfire_copy(struct pakfire* pakfire, const char* src, const char* ds FILE* f = NULL; int r = 1; + DEBUG(pakfire, "Copying %s to %s\n", src, dst); + // Allocate reader reader = archive_read_disk_new(); if (!reader) @@ -1049,8 +1051,10 @@ static int pakfire_copy(struct pakfire* pakfire, const char* src, const char* ds // Copy payload if (archive_entry_filetype(entry) == AE_IFREG) { f = fopen(src, "r"); - if (!f) + if (!f) { + r = 1; goto ERROR; + } while (!feof(f)) { size_t bytes_read = fread(buffer, 1, sizeof(buffer), f); @@ -1058,12 +1062,14 @@ static int pakfire_copy(struct pakfire* pakfire, const char* src, const char* ds // Check if any error occured if (ferror(f)) { ERROR(pakfire, "Error reading from file: %m\n"); + r = 1; goto ERROR; } ssize_t bytes_written = archive_write_data(writer, buffer, bytes_read); if (bytes_written < 0) { ERROR(pakfire, "Error writing data: %s\n", archive_error_string(writer)); + r = 1; goto ERROR; } }