summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-13 22:46:54 +0800
committerruki <[email protected]>2026-01-13 22:46:54 +0800
commit46687b17c49e44c69264fd1d899cf297475b924b (patch)
tree9799b4a9e4424b08fe0e3f46a1e057c87cbcfde0 /xmake/modules/private/action/require/impl
parent1dc17c218aa04c3a4fa7b74be0dfff6fc9b31809 (diff)
update format
Diffstat (limited to 'xmake/modules/private/action/require/impl')
-rw-r--r--xmake/modules/private/action/require/impl/lock_packages.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/xmake/modules/private/action/require/impl/lock_packages.lua b/xmake/modules/private/action/require/impl/lock_packages.lua
index f51092b47..2417a4aa0 100644
--- a/xmake/modules/private/action/require/impl/lock_packages.lua
+++ b/xmake/modules/private/action/require/impl/lock_packages.lua
@@ -66,7 +66,17 @@ function main(packages)
local packagelock_key = _get_packagelock_key(instance)
results[key][packagelock_key] = _lock_package(instance)
end
- io.writefile(project.requireslock(), string.serialize(results, {orderkeys = true}), {encoding = "binary"})
+ -- write to temporary file first, then copy if content is different
+ local lockfile = project.requireslock()
+ local content = string.serialize(results, {orderkeys = true})
+ local tmpfile = os.tmpfile()
+
+ -- write to temporary file
+ io.writefile(tmpfile, content, {encoding = "binary"})
+
+ -- copy to target file only if content is different
+ os.cp(tmpfile, lockfile, {copy_if_different = true})
+ os.rm(tmpfile)
end
end