do not remove torrent files which are not upload
[cloudstore.git] / gearman / transmission.pl
index 8e98399..a66f771 100755 (executable)
@@ -87,9 +87,6 @@ $worker->register_function( $name . '_torrent_download_done' => sub {
 
        my ( $id, $dir, $name, $hash ) = split(/\s+#\s+/,$work);
 
-       my $t = $tc->remove( $id );
-       warn "# remove $id = ",dump($t);
-
        if ( $dir =~ m{/download/(\w+)/(.+)$} ) {
                my $user = $1;
                my $path = $2;
@@ -107,14 +104,16 @@ $worker->register_function( $name . '_torrent_download_done' => sub {
                chown $uid, $gid,  "$home_dir/$path";
                warn "FIXME: add to md5 pool?";
 
+               my $t = $tc->remove( $id );
+               warn "# remove $id = ",dump($t);
+
+               warn "# $id removed $dir $name $hash\n";
+
+               remove_tree $dir;
        } else {
                warn "ERROR: can't find user in $dir for $name\n";
-               return;
        }
 
-       warn "# $id removed $dir $name $hash\n";
-
-       remove_tree $dir;
 
 } );