fix: ReplaceFile issue in luajit (windows).

This commit is contained in:
skywind3000
2019-03-09 16:56:46 +08:00
parent 1e0e3523b0
commit 86120d206e
2 changed files with 6 additions and 2 deletions
+1
View File
@@ -458,6 +458,7 @@ As you see, z.lua is the fastest one and requires less resource.
## History
- 1.7.0 (2019-03-09): Support ranger, fix ReplaceFile issue in luajit (windows).
- 1.6.0 (2019-03-04): optimize with ffi module (luajit builtin module).
- 1.5.11 (2019-03-02): fixed: os.path.isdir doesn't work for symbol link folders.
- 1.5.10 (2019-03-01): Prevent writing file racing.
+5 -2
View File
@@ -4,7 +4,7 @@
-- z.lua - a cd command that learns, by skywind 2018, 2019
-- Licensed under MIT license.
--
-- Version 1.6.0, Last Modified: 2019/03/04 14:47
-- Version 1.7.0, Last Modified: 2019/03/09 16:51
--
-- * 10x faster than fasd and autojump, 3x faster than z.sh
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -1106,7 +1106,10 @@ function data_save(filename, M)
fp:close()
if tmpname ~= nil then
if windows then
os.native.ReplaceFile(filename, tmpname)
local ok, err, code = os.rename(tmpname, filename)
if not ok then
os.native.ReplaceFile(filename, tmpname)
end
else
os.rename(tmpname, filename)
end