Skip to content

Commit

Permalink
Regenerate tmp reabank if it's missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jtackaberry committed Jun 3, 2018
1 parent b621308 commit bf4609b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/lib/utils.lua
Expand Up @@ -90,6 +90,16 @@ function file_size(fname)
end
end

function file_exists(fname)
local f, err = io.open(fname)
if f then
f:close()
return true
else
return false
end
end

function table.val_to_str(v)
if "string" == type(v) then
v = string.gsub(v, "\n", "\\n")
Expand Down
2 changes: 1 addition & 1 deletion app/reabank.lua
Expand Up @@ -729,7 +729,7 @@ function reabank.init()
local cur_factory_bank_size, err = file_size(reabank.reabank_filename_factory)
local file = get_reabank_file() or ''
local tmpnum = file:lower():match("-tmp(%d+).")
if tmpnum then
if tmpnum and file_exists(file) then
log("tmp rebeank exists: %s", file)
reabank.version = tonumber(tmpnum)
reabank.filename_tmp = file
Expand Down

0 comments on commit bf4609b

Please sign in to comment.