From 8b87a5d6d1060cd8960ae801986452beab889aec Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 27 Nov 2018 15:13:19 -0700 Subject: [PATCH] More efficient scanning --- scripts/scan_torrents.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/scan_torrents.sh b/scripts/scan_torrents.sh index 09a1ab8..205bf4d 100755 --- a/scripts/scan_torrents.sh +++ b/scripts/scan_torrents.sh @@ -70,7 +70,7 @@ for torrent_file in *.torrent; do if [ "$found_seeders" != "$seeders" ]; then # Delete the original infohash line - rg -N -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv + rg -Nv "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv # Append the add lines to the torrents.csv file echo -e "\n$add_line" >> $torrents_csv @@ -90,8 +90,11 @@ for torrent_file in *.torrent; do # Deleting the line if it existed if [ ! -z "$infohash" ]; then # This removes lines that have no seeders - echo -e "$name has no seeders, removing if existed." - grep -v "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv + echo -e "$name has no seeders" + if rg -Nq $infohash $torrents_csv; then + echo "Removing $name from $torrents_csv" + rg -Nv "$infohash" $torrents_csv > torfile.tmp.2; mv torfile.tmp.2 $torrents_csv + fi fi fi