mldonkey-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-users] [PATCH 2/7] pause conditions: "pause where priority < X


From: ygrek
Subject: [Mldonkey-users] [PATCH 2/7] pause conditions: "pause where priority < X"
Date: Mon, 18 Jun 2012 00:20:37 +0300

---
 src/daemon/driver/driverCommands.ml |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/daemon/driver/driverCommands.ml 
b/src/daemon/driver/driverCommands.ml
index 1b5e346..bffae08 100644
--- a/src/daemon/driver/driverCommands.ml
+++ b/src/daemon/driver/driverCommands.ml
@@ -3137,18 +3137,23 @@ let _ =
     ), "<num> :\t\t\tverify chunks of file <num>";
 
     "pause", Arg_multiple (fun args o ->
-        if args = ["all"] && user2_is_admin o.conn_user.ui_user then
-          List.iter (fun file ->
-              file_pause file (admin_user ())
-          ) !!files
-        else
-          List.iter (fun num ->
-              let num = int_of_string num in
-              List.iter (fun file ->
-                  if (as_file_impl file).impl_file_num = num then
-                      file_pause file o.conn_user.ui_user
-              ) !!files) args; ""
-    ), "<num|all> :\t\t\tpause a download (use arg 'all' for all files)";
+      let filter = 
+        match args with (* TODO richer condition language *)
+        | ["where";"priority";(">"|"<" as op);n] ->
+          let n = int_of_string n in
+          let op = if op = ">" then (>) else (<) in
+          (fun file -> op (file_priority file) n)
+        | ["all"] -> (fun _ -> true)
+        | l ->
+          let l = List.map int_of_string l in
+          (fun file -> List.mem (file_num file) l)
+      in
+      List.iter begin fun file ->
+        if filter file then
+          file_pause file o.conn_user.ui_user
+      end !!files;
+      ""
+    ), "<num|all|where priority < prio> :\t\t\tpause a download (use arg 'all' 
for all files)";
 
     resume_alias "resume";
     resume_alias "unpause";
-- 
1.7.10




reply via email to

[Prev in Thread] Current Thread [Next in Thread]