fix `uci import` with not yet existing packages
authorAlexander Couzens <lynxis@fe80.eu>
Wed, 19 Mar 2014 12:50:01 +0000 (13:50 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 1 Apr 2014 15:57:56 +0000 (17:57 +0200)
uci_file_commit() tries to open and lock a package file (e.g.
/etc/config/system)
before writing into. When the package file doesn't exist, uci fails with
'Entry not found'.

file.c

diff --git a/file.c b/file.c
index 36bfdda7272dbb4409442932158293436c345da2..04973f395655361bf9a3adede6e82d254a2a7a4c 100644 (file)
--- a/file.c
+++ b/file.c
@@ -714,7 +714,7 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
                UCI_THROW(ctx, UCI_ERR_IO);
 
        /* open the config file for writing now, so that it is locked */
-       f1 = uci_open_stream(ctx, p->path, SEEK_SET, false, false);
+       f1 = uci_open_stream(ctx, p->path, SEEK_SET, true, true);
 
        /* flush unsaved changes and reload from delta file */
        UCI_TRAP_SAVE(ctx, done);