Kaynağa Gözat

Detect and optionally delete duplicates

Zachary Kotlarek 12 yıl önce
ebeveyn
işleme
7384f739c6
1 değiştirilmiş dosya ile 10 ekleme ve 0 silme
  1. 10 0
      yt/subscribe.pl

+ 10 - 0
yt/subscribe.pl

@@ -322,6 +322,16 @@ sub findFiles($) {
 			);
 			$tmp{'nfo'} = $tmp{'path'};
 			$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;
 		}
 	}