diff options
author | Frank Ch. Eigler <fche@redhat.com> | 2019-08-01 08:42:38 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2019-08-01 08:42:38 -0400 |
commit | 01e76a65db197e7bee250781e2b67922cc46974b (patch) | |
tree | 6908b0c01dbb193d49e6520e6167a30db85742a2 /dbgserver | |
parent | 553e88b5c08c106fc517cae0422ee263d63b4c96 (diff) | |
download | elfutils-01e76a65db197e7bee250781e2b67922cc46974b.tar.gz |
dbgserver client: restore empty-directory cleanup
Diffstat (limited to 'dbgserver')
-rw-r--r-- | dbgserver/dbgserver-client.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dbgserver/dbgserver-client.c b/dbgserver/dbgserver-client.c index e51b2a08..57af8436 100644 --- a/dbgserver/dbgserver-client.c +++ b/dbgserver/dbgserver-client.c @@ -158,6 +158,7 @@ dbgclient_clean_cache(char *cache_path, char *interval_path) return -errno; FTSENT *f; + DIR *d; while ((f = fts_read(fts)) != NULL) { switch (f->fts_info) @@ -167,10 +168,24 @@ dbgclient_clean_cache(char *cache_path, char *interval_path) /* XXX: ->st_mtime is the wrong metric. We'd want to track -usage- not the mtime, which we copy from the http Last-Modified: header, and represents the upstream file's mtime. */ /* XXX clean_interval should be a separate parameter max_unused_age */ + /* XXX consider extra effort to clean up old tmp files */ if (time(NULL) - f->fts_statp->st_mtime >= clean_interval) unlink (f->fts_path); break; + case FTS_DP: + d = opendir(f->fts_path); + if (d) + { + /* delete directory if it doesn't contain files besides . and .. */ + (void) readdir(d); + (void) readdir(d); + if (readdir(d) == NULL) + remove(f->fts_path); + closedir(d); + } + break; + default: ; } |