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

Support single-hash processing

Zachary Kotlarek 13 лет назад
Родитель
Сommit
b5eb6d5ae6
1 измененных файлов с 17 добавлено и 2 удалено
  1. 17 2
      transmission.pl

+ 17 - 2
transmission.pl

@@ -45,7 +45,12 @@ if ($ENV{'DEBUG'}) {
 }
 }
 
 
 # Command-line parameters
 # Command-line parameters
-my ($force, $maxDays) = @ARGV;
+my ($force, $maxDays, $hash) = @ARGV;
+
+# If a hash is provided, always process matching torrents
+if (defined($hash)) {
+	$force = 1;
+}
 
 
 # Init
 # Init
 my $fetch = Fetch->new();
 my $fetch = Fetch->new();
@@ -94,8 +99,18 @@ foreach my $tor (@{$torrents}) {
 		}
 		}
 		next;
 		next;
 	}
 	}
+
+	# If a hash is provided, process only that file
+	if (defined($hash) && $tor->{'hashString'} ne $hash) {
+		if ($DEBUG) {
+			printf STDERR 'Skipping torrent with non-matching hash: ' . $tor->{'name'} . ' (' . $tor->{'hashString'} . ")\n";
+		}
+		next;
+	}
+
+	# We've decided to do something about this torrent
 	if ($DEBUG) {
 	if ($DEBUG) {
-		print STDERR 'Processing finished torrent: ' . $tor->{'name'} . "\n";
+		print STDERR 'Processing completed torrent: ' . $tor->{'name'} . "\n";
 	}
 	}
 
 
 	# Handle individual files and directories
 	# Handle individual files and directories