summaryrefslogtreecommitdiff
path: root/script/filewatch.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/filewatch.lua')
-rw-r--r--script/filewatch.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/script/filewatch.lua b/script/filewatch.lua
index e8c54d62..17a0548b 100644
--- a/script/filewatch.lua
+++ b/script/filewatch.lua
@@ -5,6 +5,16 @@ local await = require 'await'
local MODIFY = 1 << 0
local RENAME = 1 << 1
+local function exists(filename)
+ local path = fs.path(filename)
+ local suc, res = pcall(fs.exists, path)
+ if suc and res then
+ return true
+ else
+ return false
+ end
+end
+
---@class filewatch
local m = {}
@@ -53,7 +63,7 @@ function m.update()
local changes = {}
for path, flag in pairs(collect) do
if flag & RENAME ~= 0 then
- if fs.exists(fs.path(path)) then
+ if exists(path) then
changes[#changes+1] = {
type = 'create',
path = path,