use absolute path for metadata
This is possible since we bundled nativefs and started using LÖVE's Physfs.
This commit is contained in:
parent
7da38acc0e
commit
189c0c9e75
|
@ -1,10 +1,14 @@
|
|||
load_metadata = function(filename)
|
||||
local mfile = metadata_file(filename)
|
||||
local mpath = save_dir_path(mfile)
|
||||
if not love.filesystem.getInfo(mpath) then
|
||||
local mpath = full_path(mfile)
|
||||
if not nativefs.getInfo(mpath) then
|
||||
-- comments will always have metadata,
|
||||
-- so we only get here for top-level posts with no parent
|
||||
return {replies={}}
|
||||
end
|
||||
return json.decode(love.filesystem.read(mpath))
|
||||
end
|
||||
local contents, err = App.read_file(mpath)
|
||||
if not contents then
|
||||
error(err)
|
||||
end
|
||||
return json.decode(contents)
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
full_path = function(id)
|
||||
return love.filesystem.getSaveDirectory()..'/'..Data_dir..'/'..id
|
||||
end
|
||||
return App.save_dir..Data_dir..'/'..id
|
||||
end
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
save_dir_path = function(id)
|
||||
return Data_dir..'/'..id
|
||||
end
|
|
@ -3,9 +3,13 @@ save_metadata = function(node)
|
|||
local mfile = metadata_file(node.id)
|
||||
local mpath
|
||||
if node.metadata.parent then
|
||||
mpath = save_dir_path('comments/'..mfile)
|
||||
mpath = full_path('comments/'..mfile)
|
||||
else
|
||||
mpath = save_dir_path(mfile)
|
||||
mpath = full_path(mfile)
|
||||
end
|
||||
love.filesystem.write(mpath, json.encode(node.metadata))
|
||||
end
|
||||
print('saving metadata for', node.id, 'to', mpath)
|
||||
local status, err = App.write_file(mpath, json.encode(node.metadata))
|
||||
if err then
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -245,12 +245,6 @@
|
|||
"w": 600,
|
||||
"h": 520,
|
||||
},
|
||||
"save_dir_path": {
|
||||
"x": 1904.7154211416,
|
||||
"y": 5161.1643669644,
|
||||
"w": 600,
|
||||
"h": 78,
|
||||
},
|
||||
"Reply_button_border_color": {
|
||||
"x": 1861.3857767887,
|
||||
"y": -294.16322368905,
|
||||
|
|
Loading…
Reference in New Issue