소스 검색

Detect and optionally delete duplicates

Zachary Kotlarek 12 년 전
부모
커밋
7384f739c6
1개의 변경된 파일과 10개의 추가작업 그리고 0개의 파일을 삭제
  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;
 		}
 	}