diff --git a/files.py b/files.py index 51dc053..716d330 100644 --- a/files.py +++ b/files.py @@ -265,17 +265,30 @@ def fix_dups(): per_file_dups=[] per_path_dups=[] hashes="" + overall_dup_cnt=0 + overall_dup_sets=0 for hash in dups: + # more than 2 files (just ask per file) if len(dups[hash]) > 2: per_file_dups.append(dups[hash]) + overall_dup_cnt += len(dups[hash]) + overall_dup_sets += 1 + # only 2 copies, and files are in same dir (so must be diff name, so just ask) elif dups[hash][0]['d'] == dups[hash][1]['d']: per_file_dups.append(dups[hash]) + overall_dup_cnt += len(dups[hash]) + overall_dup_sets += 1 + # content same, filename different (just ask per file) elif dups[hash][0]['f'] != dups[hash][1]['f']: per_file_dups.append(dups[hash]) + overall_dup_cnt += len(dups[hash]) + overall_dup_sets += 1 # by here we have only 2 files, with the same name, different path # (MOST COMMON, and I think we dont care per file, just per path) elif d1 != dups[hash][0]['d']: if d1 != '': + overall_dup_cnt += dup_cnt + overall_dup_sets += 1 per_path_dups.append({'count': dup_cnt, 'd1': d1, 'd2': d2, 'did1': did1, 'did2': did2, 'hashes' : hashes }) dup_cnt=1 d1 = dups[hash][0]['d'] @@ -289,8 +302,11 @@ def fix_dups(): hashes += f"{hash}," if d1 != '': + overall_dup_cnt += dup_cnt + overall_dup_sets += dup_cnt per_path_dups.append({'count': dup_cnt, 'd1': d1, 'd2': d2, 'did1': did1, 'did2': did2, 'hashes' : hashes }) - return render_template("dups.html", per_file_dups=per_file_dups, per_path_dups=per_path_dups, fe_msg_id=request.form['fe_msg_id'] ) + + return render_template("dups.html", per_file_dups=per_file_dups, per_path_dups=per_path_dups, fe_msg_id=request.form['fe_msg_id'], overall_dup_cnt=overall_dup_cnt, overall_dup_sets=overall_dup_sets ) @app.route("/rm_dups", methods=["POST"]) def rm_dups(): diff --git a/templates/dups.html b/templates/dups.html index aa0b7e4..6df0968 100644 --- a/templates/dups.html +++ b/templates/dups.html @@ -7,6 +7,7 @@ 'Delete Duplicates', the files / directories in red will be deleted from the file system, those in green will remain +