Просмотр исходного кода

Detect and optionally delete duplicates

Zachary Kotlarek 12 лет назад
Родитель
Сommit
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;
 		}
 	}