Do not remove and regenerate file via .file() if not needed - stahg-gopher - Static Mercurial page generator for gopher HTML hg clone https://bitbucket.org/iamleot/stahg-gopher DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR changeset e1bbdedd6f75e5e8be656602737d3c69a810c23c DIR parent 62096a70ea4aa36f8a046b6e23f40cff334f0a40 HTML Author: Leonardo Taccari <iamleot@gmail.com> Date: Fri, 7 Jun 2019 15:08:12 Do not remove and regenerate file via .file() if not needed Diffstat: stahg-gopher.py | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) --- diff -r 62096a70ea4a -r e1bbdedd6f75 stahg-gopher.py --- a/stahg-gopher.py Thu May 16 18:47:43 2019 +0200 +++ b/stahg-gopher.py Fri Jun 07 15:08:12 2019 +0200 @@ -338,10 +338,12 @@ sh.files() sh.refs() - shutil.rmtree('file', ignore_errors=True) - os.makedirs('file', exist_ok=True) - for e in sh.client.manifest(rev=b'tip'): - sh.file(e[4]) + if not os.path.exists('commit/{changeset}.gph'.format( + changeset=sh.client['tip'].node().decode())): + shutil.rmtree('file', ignore_errors=True) + os.makedirs('file', exist_ok=True) + for e in sh.client.manifest(rev=b'tip'): + sh.file(e[4]) os.makedirs('commit', exist_ok=True) for e in sh.client.log():