history: do not interpret a failing stat() as an error
The most likely reason for stat() returning -1 is that the file
does not exist. And an absent positionlog file is not an error.
(In some cases it is, like immediately after writing the file,
but even then we don't want to complain, because it may have
been some other process that deleted the file straightaway.)
This fixes https://savannah.gnu.org/bugs/?58993.
Bug existed since version 5.0, commit fcb9e58b
.
master
parent
7ffbf01607
commit
b60fec5db3
|
@ -447,9 +447,7 @@ void load_poshistory(void)
|
|||
|
||||
free(line);
|
||||
|
||||
if (stat(poshistname, &fileinfo) == -1)
|
||||
jot_error(N_("Error reading %s: %s\n"), poshistname, strerror(errno));
|
||||
else
|
||||
if (stat(poshistname, &fileinfo) == 0)
|
||||
latest_timestamp = fileinfo.st_mtime;
|
||||
}
|
||||
|
||||
|
@ -493,9 +491,7 @@ void save_poshistory(void)
|
|||
if (fclose(histfile) == EOF)
|
||||
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
|
||||
|
||||
if (stat(poshistname, &fileinfo) == -1)
|
||||
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
|
||||
else
|
||||
if (stat(poshistname, &fileinfo) == 0)
|
||||
latest_timestamp = fileinfo.st_mtime;
|
||||
}
|
||||
|
||||
|
@ -504,9 +500,7 @@ void reload_positions_if_needed(void)
|
|||
{
|
||||
struct stat fileinfo;
|
||||
|
||||
if (stat(poshistname, &fileinfo) == -1)
|
||||
jot_error(N_("Error reading %s: %s\n"), poshistname, strerror(errno));
|
||||
else if (fileinfo.st_mtime != latest_timestamp) {
|
||||
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
|
||||
poshiststruct *item, *nextone;
|
||||
|
||||
for (item = position_history; item != NULL; item = nextone) {
|
||||
|
|
Loading…
Reference in New Issue