Skip to content

Commit

Permalink
fix: if disk has no enough space, client return failed (#973)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Feb 11, 2025
1 parent 5b287fe commit 4407ecd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
]

[workspace.package]
version = "0.2.7"
version = "0.2.8"
authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/client.git"
Expand All @@ -22,13 +22,13 @@ readme = "README.md"
edition = "2021"

[workspace.dependencies]
dragonfly-client = { path = "dragonfly-client", version = "0.2.7" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.7" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.7" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.7" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.7" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.7" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.7" }
dragonfly-client = { path = "dragonfly-client", version = "0.2.8" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.8" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.8" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.8" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.8" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.8" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.8" }
thiserror = "1.0"
dragonfly-api = "=2.1.23"
reqwest = { version = "0.12.4", features = [
Expand Down
15 changes: 6 additions & 9 deletions dragonfly-client/src/resource/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,13 @@ impl Task {
content_length,
);

// If the task is not found, check if the storage has enough space to
// If the task is not finished, check if the storage has enough space to
// store the task.
if let Ok(None) = self.get(id) {
let has_enough_space = self.storage.has_enough_space(content_length)?;
if !has_enough_space {
return Err(Error::NoSpace(format!(
"not enough space to store the persistent cache task: content_length={}",
content_length
)));
}
if !task.is_finished() && !self.storage.has_enough_space(content_length)? {
return Err(Error::NoSpace(format!(
"not enough space to store the persistent cache task: content_length={}",
content_length
)));
}

self.storage.download_task_started(
Expand Down

0 comments on commit 4407ecd

Please sign in to comment.