diff --git a/lzwfs/lzwfs.lua b/lzwfs/lzwfs.lua index 3c2a7ee..46aa869 100644 --- a/lzwfs/lzwfs.lua +++ b/lzwfs/lzwfs.lua @@ -157,9 +157,11 @@ local function split(str, pattern) end local function matchesFilter(fname) - for _, filter in pairs(filters) do - if fname:match(filter) then - return true + if not fname:find('lzwfs') then -- don't compress anything with lzwfs in name (sigh) + for _, filter in pairs(filters) do + if fname:match(filter) then + return true + end end end end @@ -193,7 +195,7 @@ function fs.open(fname, flags) end, } elseif flags == 'w' or flags == 'a' then - if not matchesFilter(fs.combine(fname, '')) or true then + if not matchesFilter(fs.combine(fname, '')) then return native.open(fname, flags) end diff --git a/lzwfs/startup.lua b/lzwfs/startup.lua index b12b64d..03a21c6 100644 --- a/lzwfs/startup.lua +++ b/lzwfs/startup.lua @@ -15,4 +15,4 @@ end os.run(_ENV, '/packages/lzwfs/lzwfs.lua') fs.option('compression', 'filters', config.filters) -fs.option('compression', 'enable', config.enabled) +fs.option('compression', 'enabled', config.enabled) diff --git a/lzwfs/system/lzwfs.lua b/lzwfs/system/lzwfs.lua index f22335c..90e2ce8 100644 --- a/lzwfs/system/lzwfs.lua +++ b/lzwfs/system/lzwfs.lua @@ -7,9 +7,9 @@ local fs = _G.fs local config = Config.load('lzwfs', { enabled = false, filters = { - '/packages', - '/sys', - '/usr/config', + 'packages/', + 'sys/', + 'usr/config/', } }) @@ -70,8 +70,10 @@ local function rewriteFiles(p) local function recurse(path) _G._syslog('rewriting: ' .. path) if fs.isDir(path) then - for _, v in pairs(fs.list(path)) do - recurse(fs.combine(path, v)) + for _, v in pairs(fs.listEx(path)) do + if not v.isReadOnly then + recurse(fs.combine(path, v.name)) + end end else local c = Util.readFile(path) @@ -116,7 +118,7 @@ function tab:eventHandler(event) if self.checkbox.value ~= config.enabled then if not self.checkbox.value then fs.option('compression', 'filters', { }) - self:rewriteFiles(config.filters) + rewriteFiles(config.filters) fs.option('compression', 'enabled', false) else fs.option('compression', 'enabled', true)