diff --git a/aniphallow.lua b/aniphallow.lua index 78fd118..25e2f92 100644 --- a/aniphallow.lua +++ b/aniphallow.lua @@ -1267,6 +1267,11 @@ local function removeLockFile() os.remove(LOCK_FILE) end +local function refreshLockFile() + local lf = io.open(LOCK_FILE, "w") + if lf then lf:write(tostring(os.time())); lf:close() end +end + ---------------------------------------------------------------------- -- Preview Window (primary window) ---------------------------------------------------------------------- @@ -1502,6 +1507,7 @@ openPreviewWindow = function() interval = 0.5, ontick = function() refreshSource() + refreshLockFile() pcall(function() previewDlg:repaint() end) -- Auto-detect file change @@ -3273,14 +3279,21 @@ local function run() return end -- Check if already running via lock file - silently ignore + -- Lock file contains a timestamp; if older than 5 seconds, consider it stale local lockF = io.open(LOCK_FILE, "r") if lockF then + local content = lockF:read("*a") lockF:close() - return + local lockTime = tonumber(content) + if lockTime and (os.time() - lockTime) < 5 then + return -- Still running, ignore + end + -- Stale lock, remove and continue + os.remove(LOCK_FILE) end - -- Create lock file + -- Create lock file with current timestamp local lf = io.open(LOCK_FILE, "w") - if lf then lf:write("running"); lf:close() end + if lf then lf:write(tostring(os.time())); lf:close() end S.currentTab = "Animations" refreshSource()