fix tmp file location

fix tmp file location, moved from datadir to a direcotry in /tmp or
configurable via env: LITE_CACHE
master
Alessandro Mauri 3 years ago
parent 364df2e1c8
commit ace6110807
  1. 4
      TODO
  2. 2
      data/core/common.lua
  3. 6
      data/core/init.lua
  4. 1
      src/main.c

@ -14,9 +14,11 @@
[ ] add a cross to close tab [ ] add a cross to close tab
[ ] prevent overscrolling on treeview [ ] prevent overscrolling on treeview
[x] user config file and/or init.lua [x] user config file and/or init.lua
[ ] change tmp directory to somewhere in /tmp [x] change tmp directory to somewhere in /tmp
[x] save project directory and restore on reopening [x] save project directory and restore on reopening
[ ] optimize dir tree taking too long to load on big folders [ ] optimize dir tree taking too long to load on big folders
[ ] SDL: optimize drawing operations
[ ] syntax: do not reload syntax on every draw event
[ ] go in background when launching from terminal [ ] go in background when launching from terminal
[ ] some key bindings: [ ] some key bindings:
[x] alt+right == End [x] alt+right == End

@ -81,7 +81,7 @@ function common.fuzzy_match(haystack, needle)
return system.fuzzy_match(haystack, needle) return system.fuzzy_match(haystack, needle)
end end
-- FIXME: why does this crash when specifying path?
function common.path_suggest(text) function common.path_suggest(text)
local path, name = text:match("^(.-)([^/\\]*)$") local path, name = text:match("^(.-)([^/\\]*)$")
local files = system.list_dir(path == "" and "." or path) or {} local files = system.list_dir(path == "" and "." or path) or {}

@ -157,16 +157,16 @@ local temp_file_prefix = string.format(".lite_temp_%08x", temp_uid)
local temp_file_counter = 0 local temp_file_counter = 0
local function delete_temp_files() local function delete_temp_files()
for _, filename in ipairs(system.list_dir(EXEDIR)) do for _, filename in ipairs(system.list_dir(TEMPDIR)) do
if filename:find(temp_file_prefix, 1, true) == 1 then if filename:find(temp_file_prefix, 1, true) == 1 then
os.remove(EXEDIR .. PATHSEP .. filename) os.remove(TEMPDIR .. PATHSEP .. filename)
end end
end end
end end
function core.temp_filename(ext) function core.temp_filename(ext)
temp_file_counter = temp_file_counter + 1 temp_file_counter = temp_file_counter + 1
return EXEDIR .. PATHSEP .. temp_file_prefix return TEMPDIR .. PATHSEP .. temp_file_prefix
.. string.format("%06x", temp_file_counter) .. (ext or "") .. string.format("%06x", temp_file_counter) .. (ext or "")
end end

@ -96,6 +96,7 @@ int main(int argc, char **argv)
"xpcall(function()\n" "xpcall(function()\n"
" SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n" " SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n"
" USERDIR = os.getenv(\"HOME\") .. '/.config/lite'\n" " USERDIR = os.getenv(\"HOME\") .. '/.config/lite'\n"
" TEMPDIR = os.getenv(\"LITE_CACHE\") or '/tmp'\n"
" PATHSEP = package.config:sub(1, 1)\n" " PATHSEP = package.config:sub(1, 1)\n"
" EXEDIR = EXEFILE:match(\"^(.+)[/\\\\].*$\")\n" " EXEDIR = EXEFILE:match(\"^(.+)[/\\\\].*$\")\n"
" package.path = EXEDIR .. '/data/?.lua;' .. package.path\n" " package.path = EXEDIR .. '/data/?.lua;' .. package.path\n"

Loading…
Cancel
Save