diff options
author | Naïm Favier <n@monade.li> | 2021-11-16 00:33:37 +0100 |
---|---|---|
committer | Naïm Favier <n@monade.li> | 2021-11-17 15:09:15 +0100 |
commit | cfcc6f194cfc95ab0cf1b3b719d77321c249a83b (patch) | |
tree | 59738effaa44345594b2c4f5fdbb287700c19402 | |
parent | d53d31d2dbab00e13e23862cf2bf88da532b9465 (diff) | |
download | ibus-cfcc6f194cfc95ab0cf1b3b719d77321c249a83b.tar.gz |
src/ibuscomposetable: invalidate cache based on symlink mtime too
When the compose file is a symbolic link, take the link itself's
modification time into account (in addition to its target's) in
determining whether to invalidate the compose cache.
This is useful e.g. on NixOS systems where the compose file might point
to a store path with an irrelevant modification time, and we want the
cache to expire when the symlink itself changes.
BUG=https://github.com/ibus/ibus/pull/2362
-rw-r--r-- | src/ibuscomposetable.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c index b76464bc..250e0139 100644 --- a/src/ibuscomposetable.c +++ b/src/ibuscomposetable.c @@ -1040,10 +1040,14 @@ ibus_compose_table_load_cache (const gchar *compose_file) if (!g_file_test (path, G_FILE_TEST_EXISTS)) break; - if (g_stat (compose_file, &original_buf)) - break; if (g_stat (path, &cache_buf)) break; + if (g_lstat (compose_file, &original_buf)) + break; + if (original_buf.st_mtime > cache_buf.st_mtime) + break; + if (g_stat (compose_file, &original_buf)) + break; if (original_buf.st_mtime > cache_buf.st_mtime) break; if (!g_file_get_contents (path, &contents, &length, &error)) { |