gluon-core: sysconfig: avoid unnecessary writes

Do not write files when the content is unchanged.

Avoids a few unnecessary filesystem writes when resetting ifname
sysconfigs on each upgrade.
This commit is contained in:
Matthias Schiffer 2021-12-28 20:41:29 +01:00
parent c2a5f57c40
commit 05c29512ec
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -11,6 +11,10 @@ local function get(_, name)
end end
local function set(_, name, val) local function set(_, name, val)
if val == get(nil, name) then
return
end
if val then if val then
local f = io.open(sysconfigdir .. name, 'w+') local f = io.open(sysconfigdir .. name, 'w+')
f:write(val, '\n') f:write(val, '\n')