rc_newer_than no longer tests if souce has data, making it a more logical function. As such, we add the existss function to check for existance and size when checking to see if the deptree needs an update.
This commit is contained in:
parent
b29c4aa926
commit
3e0f49b846
@ -111,6 +111,12 @@ static inline bool exists (const char *pathname)
|
|||||||
return (stat (pathname, &buf) == 0);
|
return (stat (pathname, &buf) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool existss (const char *pathname)
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
|
return (stat (pathname, &buf) == 0 && buf.st_size != 0);
|
||||||
|
}
|
||||||
char *rc_conf_value (const char *var);
|
char *rc_conf_value (const char *var);
|
||||||
bool rc_conf_yesno (const char *var);
|
bool rc_conf_yesno (const char *var);
|
||||||
char **env_filter (void);
|
char **env_filter (void);
|
||||||
|
@ -606,7 +606,8 @@ bool rc_newer_than (const char *source, const char *target)
|
|||||||
char *path;
|
char *path;
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
|
|
||||||
if (stat (source, &buf) != 0 || buf.st_size == 0)
|
/* We have to exist */
|
||||||
|
if (stat (source, &buf) != 0)
|
||||||
return (false);
|
return (false);
|
||||||
mtime = buf.st_mtime;
|
mtime = buf.st_mtime;
|
||||||
|
|
||||||
@ -618,11 +619,13 @@ bool rc_newer_than (const char *source, const char *target)
|
|||||||
if (mtime < buf.st_mtime)
|
if (mtime < buf.st_mtime)
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
|
/* If not a dir then reset errno */
|
||||||
if (! (dp = opendir (target))) {
|
if (! (dp = opendir (target))) {
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if we're newer than all the entries in the dir */
|
||||||
while ((d = readdir (dp))) {
|
while ((d = readdir (dp))) {
|
||||||
if (d->d_name[0] == '.')
|
if (d->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
@ -682,8 +685,10 @@ bool rc_deptree_update_needed (void)
|
|||||||
if (mkdir (depdirs[i], 0755) != 0 && errno != EEXIST)
|
if (mkdir (depdirs[i], 0755) != 0 && errno != EEXIST)
|
||||||
fprintf (stderr, "mkdir `%s': %s\n", depdirs[i], strerror (errno));
|
fprintf (stderr, "mkdir `%s': %s\n", depdirs[i], strerror (errno));
|
||||||
|
|
||||||
/* Quick test to see if anything we use has changed */
|
/* Quick test to see if anything we use has changed and we have
|
||||||
if (! rc_newer_than (RC_DEPTREE, RC_INITDIR) ||
|
* data in our deptree */
|
||||||
|
if (! existss (RC_DEPTREE) ||
|
||||||
|
! rc_newer_than (RC_DEPTREE, RC_INITDIR) ||
|
||||||
! rc_newer_than (RC_DEPTREE, RC_CONFDIR) ||
|
! rc_newer_than (RC_DEPTREE, RC_CONFDIR) ||
|
||||||
! rc_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) ||
|
! rc_newer_than (RC_DEPTREE, RC_INITDIR_LOCAL) ||
|
||||||
! rc_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) ||
|
! rc_newer_than (RC_DEPTREE, RC_CONFDIR_LOCAL) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user