From 14c45b3657700d286cbe857c1add576fa3ddee5a Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 25 Feb 2019 15:22:29 +0200 Subject: augeas back-end: fix ordering of sequence nodes --- aconf/persistence/backends/augeas.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'aconf') diff --git a/aconf/persistence/backends/augeas.lua b/aconf/persistence/backends/augeas.lua index eb954e8..b3bcd2c 100644 --- a/aconf/persistence/backends/augeas.lua +++ b/aconf/persistence/backends/augeas.lua @@ -1,5 +1,5 @@ --[[ -Copyright (c) 2012-2015 Kaarle Ritvanen +Copyright (c) 2012-2019 Kaarle Ritvanen See LICENSE file for license details --]] @@ -236,10 +236,16 @@ function backend:set(mods) local ord = order(path) for _, sibling in ipairs(matches) do - local sord = order(array_join(parent, basename(sibling))) - if sord and sord > ord then - self.aug:insert(sibling, name, true) - return apath, keys + local sname = basename(sibling) + local sord = order(array_join(parent, sname)) + if sord then + local snum = tonumber(sname) + if sord > ord or ( + sord == ord and snum and type(name) == 'number' and snum > name + ) then + self.aug:insert(sibling, name, true) + return apath, keys + end end end end -- cgit v1.2.3