From 590c83148ed9f40ac27dc73d64ca5aae5442cbfc Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Wed, 29 Sep 2021 11:38:03 +0200 Subject: [PATCH] Enable inotify specific api only on linux --- data/core/init.lua | 22 +++++++++++++--------- src/api/system.c | 6 +++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 4ee5d796..2939d966 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -155,13 +155,15 @@ function core.project_subdir_set_show(dir, filename, show) dir.shown_subdir[filename] = show if dir.files_limit then local fullpath = dir.name .. PATHSEP .. filename - if show then - local success = system.watch_dir_add(dir.watch_id, fullpath) - print("DEBUG: watch_dir_add", fullpath, "success:", success) - else - print("DEBUG dir", dir.name, "filename", filename, "watch_id:", dir.watch_id) - local success = system.watch_dir_rm(dir.watch_id, fullpath) - print("DEBUG: watch_dir_rm", fullpath, "success:", success) + if PLATFORM == "Linux" then + if show then + local success = system.watch_dir_add(dir.watch_id, fullpath) + print("DEBUG: watch_dir_add", fullpath, "success:", success) + else + print("DEBUG dir", dir.name, "filename", filename, "watch_id:", dir.watch_id) + local success = system.watch_dir_rm(dir.watch_id, fullpath) + print("DEBUG: watch_dir_rm", fullpath, "success:", success) + end end end end @@ -187,8 +189,10 @@ local function scan_project_folder(index) if entries_count > config.max_project_files then print("DEBUG setting files limit FLAG for", dir.name) dir.files_limit = true - -- Watch non-recursively - dir.watch_id = system.watch_dir(dir.name, false) + -- Watch non-recursively on Linux only. + -- The reason is recursively watching with dmon on linux + -- doesn't work on very large directories. + dir.watch_id = system.watch_dir(dir.name, PLATFORM ~= "Linux") if core.status_view then -- May be not yet initialized. show_max_files_warning() end diff --git a/src/api/system.c b/src/api/system.c index d8e27053..a6495986 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -656,6 +656,7 @@ static int f_watch_dir(lua_State *L) { return 1; } +#if __linux__ static int f_watch_dir_add(lua_State *L) { dmon_watch_id watch_id; watch_id.id = luaL_checkinteger(L, 1); @@ -672,6 +673,7 @@ static int f_watch_dir_rm(lua_State *L) { lua_pushboolean(L, dmon_watch_rm(watch_id, subdir)); return 1; } +#endif #ifdef _WIN32 #define PATHSEP '\\' @@ -758,9 +760,11 @@ static const luaL_Reg lib[] = { { "fuzzy_match", f_fuzzy_match }, { "set_window_opacity", f_set_window_opacity }, { "watch_dir", f_watch_dir }, + { "path_compare", f_path_compare }, +#if __linux__ { "watch_dir_add", f_watch_dir_add }, { "watch_dir_rm", f_watch_dir_rm }, - { "path_compare", f_path_compare }, +#endif { NULL, NULL } };