diff options
Diffstat (limited to 'webmap-download')
-rwxr-xr-x | webmap-download | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/webmap-download b/webmap-download index a8a444a..8897cf4 100755 --- a/webmap-download +++ b/webmap-download @@ -249,6 +249,8 @@ def main() -> NoReturn: # pylint: disable=missing-function-docstring help=argparse.SUPPRESS) parser.add_argument('--exit-code', default=True, action=argparse.BooleanOptionalAction, help='whether to exit with status 1 in case of download failures') + parser.add_argument('--force', default=False, action='store_true', + help='always download regardless of age') parser.add_argument('groupname', nargs='*', help='group layer name(s) to process') args = parser.parse_args() @@ -323,14 +325,16 @@ def main() -> NoReturn: # pylint: disable=missing-function-docstring # the file doesn't exist, or stat() failed for some reason pass else: - max_age = dl.get('max-age', 6*3600) # 6h - if max_age is not None: - s = max_age + max(st.st_ctime, st.st_mtime) - time() - if s > 0: - logging.info('%s: Too young, try again in %s', - dest, common.format_time(s)) - continue - headers['If-Modified-Since'] = formatdate(timeval=st.st_mtime, localtime=False, usegmt=True) + if not args.force: + max_age = dl.get('max-age', 6*3600) # 6h + if max_age is not None: + s = max_age + max(st.st_ctime, st.st_mtime) - time() + if s > 0: + logging.info('%s: Too young, try again in %s', dest, + common.format_time(s)) + continue + headers['If-Modified-Since'] = formatdate(timeval=st.st_mtime, + localtime=False, usegmt=True) download(dest, dl, dir_fd=destdir_fd, headers=headers, session=session_requests, progress=pbar) |