Fix skipping directories in uci_list_config_files
[project/uci.git] / delta.c
diff --git a/delta.c b/delta.c
index 357f5c7..e9c79ab 100644 (file)
--- a/delta.c
+++ b/delta.c
@@ -114,9 +114,8 @@ int uci_set_savedir(struct uci_context *ctx, const char *dir)
                }
        }
        if (!exists)
-               UCI_INTERNAL(uci_add_delta_path, ctx, dir);
-       else
-               uci_list_add(&ctx->delta_path, &e->list);
+               e = uci_alloc_generic(ctx, UCI_TYPE_PATH, dir, sizeof(struct uci_element));
+       uci_list_add(&ctx->delta_path, &e->list);
 
        sdir = uci_strdup(ctx, dir);
        if (ctx->savedir != uci_savedir)
@@ -294,13 +293,15 @@ static int uci_load_delta_file(struct uci_context *ctx, struct uci_package *p, c
 
        UCI_TRAP_SAVE(ctx, done);
        stream = uci_open_stream(ctx, filename, NULL, SEEK_SET, flush, false);
+       UCI_TRAP_RESTORE(ctx);
+
        if (p)
                changes = uci_parse_delta(ctx, stream, p);
-       UCI_TRAP_RESTORE(ctx);
+
 done:
        if (f)
                *f = stream;
-       else if (stream)
+       else
                uci_close_stream(stream);
        return changes;
 }