]> git.ipfire.org Git - pakfire.git/commitdiff
file: Log an error message when setting path fails
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Aug 2022 10:45:03 +0000 (10:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Aug 2022 10:45:03 +0000 (10:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/file.c

index 9470af7044aa74ad6714a752b729fcbea08ff182..0f9020ba51a6f07add98620f4a3bce862c5ce605 100644 (file)
@@ -381,27 +381,31 @@ PAKFIRE_EXPORT const char* pakfire_file_get_path(struct pakfire_file* file) {
 }
 
 PAKFIRE_EXPORT int pakfire_file_set_path(struct pakfire_file* file, const char* path) {
-       int r;
+       int r = 1;
 
        // Check if path is set and absolute
        if (!path || *path != '/') {
                errno = EINVAL;
-               return 1;
+               goto ERROR;
        }
 
        // Store path
        r = pakfire_string_set(file->path, path);
        if (r)
-               return r;
+               goto ERROR;
 
        // Set abspath if it isn't set, yet
        if (!*file->abspath) {
-               r = pakfire_path(file->pakfire, file->abspath, "%s", path);
+               r = pakfire_file_set_abspath(file, path);
                if (r)
-                       return r;
+                       goto ERROR;
        }
 
        return r;
+
+ERROR:
+       ERROR(file->pakfire, "Could not set path '%s': %m\n", path);
+       return r;
 }
 
 PAKFIRE_EXPORT const char* pakfire_file_get_hardlink(struct pakfire_file* file) {