mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 15:21:41 +01:00
cli/insert: clean up sync_dir
Clarify the code slightly, improve error messages. Apart from the error message changes, no functional changes.
This commit is contained in:
parent
9324e04a82
commit
eab18a61a9
1 changed files with 9 additions and 8 deletions
|
@ -67,20 +67,21 @@ safe_gethostname (char *hostname, size_t len)
|
||||||
static notmuch_bool_t
|
static notmuch_bool_t
|
||||||
sync_dir (const char *dir)
|
sync_dir (const char *dir)
|
||||||
{
|
{
|
||||||
notmuch_bool_t ret;
|
int fd, r;
|
||||||
int fd;
|
|
||||||
|
|
||||||
fd = open (dir, O_RDONLY);
|
fd = open (dir, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
fprintf (stderr, "Error: open() dir failed: %s\n", strerror (errno));
|
fprintf (stderr, "Error: open %s: %s\n", dir, strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ret = (fsync (fd) == 0);
|
|
||||||
if (! ret) {
|
r = fsync (fd);
|
||||||
fprintf (stderr, "Error: fsync() dir failed: %s\n", strerror (errno));
|
if (r)
|
||||||
}
|
fprintf (stderr, "Error: fsync %s: %s\n", dir, strerror (errno));
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
return ret;
|
|
||||||
|
return r == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue