Explorar o código

Detect and optionally delete duplicates

Zachary Kotlarek %!s(int64=12) %!d(string=hai) anos
pai
achega
7384f739c6
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      yt/subscribe.pl

+ 10 - 0
yt/subscribe.pl

@@ -322,6 +322,16 @@ sub findFiles($) {
 			);
 			);
 			$tmp{'nfo'} = $tmp{'path'};
 			$tmp{'nfo'} = $tmp{'path'};
 			$tmp{'nfo'} =~ s/\.\w\w\w$/\.nfo/;
 			$tmp{'nfo'} =~ s/\.\w\w\w$/\.nfo/;
+
+			if (exists($files{$id})) {
+				warn('Duplicate ID: ' . $id . "\n\t" . $files{$id}->{'path'} . "\n\t" . $tmp{'path'} . "\n");
+				if ($RENAME) {
+					print STDERR 'Deleting duplicate: ' . $files{$id}->{'path'} . "\n";
+					unlink($files{$id}->{'path'});
+					unlink($files{$id}->{'nfo'});
+					delete($files{$id});
+				}
+			}
 			$files{$id} = \%tmp;
 			$files{$id} = \%tmp;
 		}
 		}
 	}
 	}