Bug: add_tag

add_tag was creating another folder inside the target path.
This commit is contained in:
Coder12a 2019-01-14 18:49:21 -06:00
parent b700bd5c77
commit ea0fceac5e

View File

@ -26,7 +26,7 @@ function colddb.Colddb(dir)
setmetatable(mem_pool_del, {__mode = "kv"})
setmetatable(indexes_pool, {__mode = "kv"})
local function file_Exists(name, tag_name)
local function file_exists(name, tag_name)
local t = ""
if tag_name then
t = self.get_tag(tag_name)
@ -180,6 +180,10 @@ function colddb.Colddb(dir)
end)
end
self.exists = function(name, tag_name)
return file_exists(name, tag_name)
end
self.add_tag = function(name, tag, no_new_path)
local t = ""
if not tags[name] then
@ -196,7 +200,7 @@ function colddb.Colddb(dir)
if no_new_path then
return
end
local test_path = string.format("%s%s%s", directory, tags[name], t)
local test_path = string.format("%s%s", directory, tags[name])
if not minetest.mkdir(test_path) then
error(string.format("%s is not a directory.", test_path))
end
@ -271,6 +275,7 @@ function colddb.Colddb(dir)
if tag_name then
t = self.get_tag(tag_name)
end
minetest.log(string.format("%s%s%s.cold", directory, t, name))
return minetest.safe_file_write(string.format("%s%s%s.cold", directory, t, name), minetest.serialize(_table))
end
@ -336,7 +341,7 @@ function colddb.Colddb(dir)
local fs = indexes_pool[cs]
if not fs then
local p = string.format("%s%s%s.cold", directory, t, name)
if not file_Exists(name,tag_name) then
if not file_exists(name,tag_name) then
local f = io.open(p, "w")
if f then
f:seek("set")