浏览代码

Update ffsend-api dependency to version 0.2.0

timvisee 6 年之前
父节点
当前提交
614659f74b
共有 3 个文件被更改,包括 11 次插入7 次删除
  1. 3 3
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 7 3
      src/action/upload.rs

+ 3 - 3
Cargo.lock

@@ -509,7 +509,7 @@ dependencies = [
  "derive_builder 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "ffsend-api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ffsend-api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "open 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -527,7 +527,7 @@ dependencies = [
 
 [[package]]
 name = "ffsend-api"
-version = "0.2.0"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2092,7 +2092,7 @@ dependencies = [
 "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
 "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
 "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
-"checksum ffsend-api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1543de3dedf3c548a60f0064fe481441947ee33dbbde25f472fa6628bbfd2f7"
+"checksum ffsend-api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5c0516f951c32083d92f16b88d59d72b431cc2de2c3111662d6c1b5a36ef7841"
 "checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
 "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
 "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"

+ 1 - 1
Cargo.toml

@@ -75,7 +75,7 @@ colored = "1.7"
 derive_builder = "0.7"
 directories = "1.0"
 failure = "0.1"
-ffsend-api = { version = "0.2.0", default-features = false }
+ffsend-api = { version = "0.2.2", default-features = false }
 fs2 = "0.4"
 lazy_static = "1.0"
 open = "1"

+ 7 - 3
src/action/upload.rs

@@ -9,7 +9,7 @@ use failure::Fail;
 use ffsend_api::action::params::ParamsDataBuilder;
 use ffsend_api::action::upload::{Error as UploadError, Upload as ApiUpload};
 use ffsend_api::action::version::Error as VersionError;
-use ffsend_api::config::{UPLOAD_SIZE_MAX, UPLOAD_SIZE_MAX_RECOMMENDED};
+use ffsend_api::config::{upload_size_max, UPLOAD_SIZE_MAX_RECOMMENDED};
 use ffsend_api::pipe::ProgressReporter;
 use prettytable::{format::FormatBuilder, Cell, Row, Table};
 #[cfg(feature = "archive")]
@@ -63,18 +63,22 @@ impl<'a> Upload<'a> {
 
         // TODO: ensure the file exists and is accessible
 
+        // Determine the max file size
+        // TODO: set false parameter to authentication state
+        let max_size = upload_size_max(api_version, false);
+
         // Get the file size to warn about large files
         if let Ok(size) = File::open(&path)
             .and_then(|f| f.metadata())
             .map(|m| m.len())
         {
-            if size > UPLOAD_SIZE_MAX && !matcher_main.force() {
+            if size > max_size && !matcher_main.force() {
                 // The file is too large, show an error and quit
                 quit_error_msg(
                     format!(
                         "the file size is {}, bigger than the maximum allowed of {}",
                         format_bytes(size),
-                        format_bytes(UPLOAD_SIZE_MAX),
+                        format_bytes(max_size),
                     ),
                     ErrorHintsBuilder::default()
                         .force(true)