Prechádzať zdrojové kódy

Show timeout values in debug output

timvisee 6 rokov pred
rodič
commit
0768028089
2 zmenil súbory, kde vykonal 24 pridanie a 1 odobranie
  1. 23 0
      src/action/debug.rs
  2. 1 1
      src/client.rs

+ 23 - 0
src/action/debug.rs

@@ -3,6 +3,7 @@ use clap::ArgMatches;
 use ffsend_api::config::SEND_DEFAULT_EXPIRE_TIME;
 use prettytable::{Cell, format::FormatBuilder, Row, Table};
 
+use client::to_duration;
 use cmd::matcher::{debug::DebugMatcher, main::MainMatcher, Matcher};
 use error::ActionError;
 use util::{features_list, format_bool, format_duration};
@@ -42,6 +43,28 @@ impl<'a> Debug<'a> {
             Cell::new(matcher_main.history().to_str().unwrap_or("?")),
         ]));
 
+        // The timeouts
+        table.add_row(Row::new(vec![
+            Cell::new("Timeout:"),
+            Cell::new(
+                &to_duration(matcher_main.timeout())
+                    .map(|t| format_duration(
+                        Duration::from_std(t).expect("failed to convert timeout duration"),
+                    ))
+                    .unwrap_or("disabled".into())
+            ),
+        ]));
+        table.add_row(Row::new(vec![
+            Cell::new("Transfer timeout:"),
+            Cell::new(
+                &to_duration(matcher_main.transfer_timeout())
+                    .map(|t| format_duration(
+                        Duration::from_std(t).expect("failed to convert transfer timeout duration"),
+                    ))
+                    .unwrap_or("disabled".into())
+            ),
+        ]));
+
         // The default host
         table.add_row(Row::new(vec![
             Cell::new("Default expiry:"),

+ 1 - 1
src/client.rs

@@ -27,7 +27,7 @@ fn create_custom_client(timeout: Option<Duration>) -> Client {
 }
 
 /// Convert the given number of seconds into an optional duration, used for clients.
-fn to_duration(secs: u64) -> Option<Duration> {
+pub fn to_duration(secs: u64) -> Option<Duration> {
     if secs > 0 {
         Some(Duration::from_secs(secs))
     } else {