From 697bc0ebc8178488cdb837b584b47d965b421b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 20 Nov 2015 15:21:49 +0100 Subject: text: get modification time after replacing file content in place At the start of text_save_range we stat(2) the file to check whether we have currently mmap(2)-ed it. Then we proceed to write the new file content which changes modification time. Hence we have to stat(2) again to retrieve it. This should fix spurious warnings about file changes outside the editor when editing e.g. symlinked files. --- text.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/text.c b/text.c index 92e961c..1e1c968 100644 --- a/text.c +++ b/text.c @@ -988,6 +988,8 @@ bool text_save_range(Text *txt, Filerange *range, const char *filename) { if (fsync(fd) == -1) goto err; + if (fstat(fd, &meta) == -1) + goto err; if (close(fd) == -1) return false; txt->info = meta; -- cgit v1.2.3