From 18b9ae59be8219f6fa36bf945a8731b6102dd5c1 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 19 Jun 2021 17:16:47 +1000 Subject: [PATCH] redid accounting for duplicates with more details around manual choices and fixed up the file counts that were based on subtractions, its all now accounted and includes removal of duplicates in rare case of files in import path and more than copy in storage path being double-counted --- templates/dups.html | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/templates/dups.html b/templates/dups.html index 4bbf8c4..434e116 100644 --- a/templates/dups.html +++ b/templates/dups.html @@ -66,7 +66,7 @@ {% set page=namespace(cnt=0) %} {% set pref=namespace(have="") %} {% set count=namespace( del=0, keep=0 ) %} - {% set all_count=namespace( d_files=0, k_files=0, manual=0 ) %} + {% set all_count=namespace( d_files=0, k_files=0, md_files=0, mk_files=0, manual=0 ) %} {% set kfid=namespace( count=0 ) %} {# for each hash in ip_to_sp_dups_*, auto keep the _keep, auto delete the _del, only need hidden input #} {% for h in DD.ip_to_sp_dups_keep %} @@ -82,7 +82,7 @@ {% set all_count.d_files = all_count.d_files + count.del %} {% endif %}
Choose between these files:
- {% set count=namespace( del=0, keep=0 ) %} + {% set count=namespace( del=0, keep=0, man_del=0, man_keep=0 ) %} {% for dups in DD.per_file_dups %} {% set outer_loop=loop.index %} {% set pref.have="" %} @@ -96,12 +96,18 @@ {% set count.keep = count.keep + 1 %} {% else %} - {% set count.del = count.del + (dups|length-1) %} + {% set count.del = count.del + 1 %} {% endif %} {% else %} {# okay, show an alert / make it choosable for each of these manually processed dups #} {% if loop.index == 1 %} {% set all_count.manual = all_count.manual + 1 %} + {# we arent necessarily keeping this one, but we count the first as manual keep, the rest as manual del #} + {# sometimes we are both in an import dir and have multiple copies in storage dir, dont double count keep, we will keep 1 from earlier code for this hash #} + {% if dup.h not in DD.ip_to_sp_dups_keep %} + {% set count.man_keep = count.man_keep + 1 %} + {% endif %} + {% set count.man_del = count.man_del + dups|length-1 %} {% endif %} {% if page.cnt <= pagesize %} {% if loop.index == 1 %} @@ -137,9 +143,11 @@ {% set auto.str = auto.str + "
  • Keeping {} files inside storage path, Deleting {} duplicates files from storage path
  • ".format(count.keep, count.del) %} {% set all_count.k_files = all_count.k_files + count.keep %} {% set all_count.d_files = all_count.d_files + count.del %} + {% set all_count.mk_files = count.man_keep %} + {% set all_count.md_files = count.man_del %} {% endif %} - {% set count=namespace( keep_d=0, keep_f=0 ) %} + {% set count=namespace( keep_d=0, keep_f=0, m_files=0, m_dirs=0 ) %} {% for dup in DD.per_path_dups %} {% if DD.preferred_path[dup.did1] or DD.preferred_path[dup.did2] %} @@ -152,6 +160,8 @@ {% set count.keep_f = count.keep_f + dup.hashes|wordcount %} {% else %} {% set all_count.manual = all_count.manual + 1 %} + {% set count.m_files = count.m_files + dup.hashes|wordcount %} + {% set count.m_dirs = count.m_dirs +1 %} {% if page.cnt <= pagesize %}
    Choose path to KEEP (same file names in 2 different directories):
    @@ -185,6 +195,8 @@ {% set auto.str = auto.str + "
  • Keeping {} files in {} paths, Deleting={} file in {} paths
  • ".format( count.keep_f, count.keep_d, count.keep_f, count.keep_d) %} {% set all_count.k_files = all_count.k_files + count.keep_f %} {% set all_count.d_files = all_count.d_files + count.keep_f %} + {% set all_count.mk_files = all_count.mk_files + count.m_files %} + {% set all_count.md_files = all_count.md_files + count.m_files %}
    {% endif %} {% if auto.str|length %} @@ -193,7 +205,11 @@ {{auto.str|safe}} Automatically Keeping {{all_count.k_files}} files and deleting {{all_count.d_files}} files
    - Leaving {{all_count.manual}} manual choices to make (to keep {{DD.uniq_dups-all_count.k_files}} files and delete {{DD.total_dups-all_count.k_files-all_count.d_files-all_count.manual}} files) + Leaving {{all_count.manual}} manual choices to make (to keep {{all_count.mk_files}} files and delete {{all_count.md_files}} files) + +{# +So by counting/double-check, uniq files kept = {{all_count.k_files+all_count.mk_files}}, overall dups = {{all_count.k_files+all_count.d_files+all_count.mk_files+all_count.md_files}} +#} {% endif %}