+ elsif ($word[0] eq "cancel") {
+ if (@word != 2) {
+ msg( "mail,log", "Wrong number of arguments\n" );
+ }
+ elsif ($conf::upload_method ne "copy") {
+ msg( "mail,log", "cancel not available\n" );
+ }
+ elsif ($word[1] !~ m,^[a-zA-Z0-9.+_:@=%-][~a-zA-Z0-9.+_:@=%-]*\.changes$,) {
+ msg( "mail,log", "argument to cancel must be one .changes filename without path\n" );
+ }
+ my (@files);
+ for ( my($adelay)=0; $adelay <= $conf::max_delayed; $adelay++ ) {
+ my($dir) = sprintf( "$conf::targetdir_delayed",$adelay );
+ if (-f "$dir/$word[1]") {
+ push (@files, "$dir/$word[1]");
+ push (@files, map( "$dir/$_",get_filelist_from_known_good_changes("$dir/$word[1]")));
+ }
+ }
+ if (!@files) {
+ msg( "mail,log", "No upload found: $word[1]\n" );
+ }
+ else {
+ @removed = ();
+ foreach $file ( @files ) {
+ if (!-f $file) {
+ msg( "mail,log", "$file: no such file\n" );
+ }
+ elsif ($file =~ /$conf::keep_files/) {
+ msg( "mail,log", "$file is protected, cannot ".
+ "remove\n" );
+ }
+ elsif (!unlink( $file )) {
+ msg( "mail,log", "$file: rm: $!\n" );
+ }
+ else {
+ push( @removed, $file );
+ }
+ }
+ msg( "mail,log", "Files removed: @removed\n" ) if @removed;
+ }
+ }