From 26ef41bfacb94009513a4f540031ac4ae5dcd9cc Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Mon, 20 Mar 2017 09:10:17 +0100 Subject: [PATCH] Fixbug always delete source --- guetzli-recursively.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/guetzli-recursively.py b/guetzli-recursively.py index aad88db..18fbe87 100644 --- a/guetzli-recursively.py +++ b/guetzli-recursively.py @@ -29,12 +29,13 @@ for dirpath, dirnames, files in walk(top_dir): except: size_out = size_source size_acurate = 100 * size_out / size_source - # Remove source - try: - remove(url) - except: - pass + # Check if it is cost effective to replace it if size_acurate < 100: + # Remove source + try: + remove(url) + except: + pass # Move temp to source rename(url_out, url) print('Save ' + str(100 - size_acurate) + '%')