Skip to content

Commit 4407ecd

Browse files
authored
fix: if disk has no enough space, client return failed (#973)
Signed-off-by: Gaius <[email protected]>
1 parent 5b287fe commit 4407ecd

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ members = [
1212
]
1313

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

2424
[workspace.dependencies]
25-
dragonfly-client = { path = "dragonfly-client", version = "0.2.7" }
26-
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.7" }
27-
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.7" }
28-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.7" }
29-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.7" }
30-
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.7" }
31-
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.7" }
25+
dragonfly-client = { path = "dragonfly-client", version = "0.2.8" }
26+
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.8" }
27+
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.8" }
28+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.8" }
29+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.8" }
30+
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.8" }
31+
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.8" }
3232
thiserror = "1.0"
3333
dragonfly-api = "=2.1.23"
3434
reqwest = { version = "0.12.4", features = [

dragonfly-client/src/resource/task.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,13 @@ impl Task {
206206
content_length,
207207
);
208208

209-
// If the task is not found, check if the storage has enough space to
209+
// If the task is not finished, check if the storage has enough space to
210210
// store the task.
211-
if let Ok(None) = self.get(id) {
212-
let has_enough_space = self.storage.has_enough_space(content_length)?;
213-
if !has_enough_space {
214-
return Err(Error::NoSpace(format!(
215-
"not enough space to store the persistent cache task: content_length={}",
216-
content_length
217-
)));
218-
}
211+
if !task.is_finished() && !self.storage.has_enough_space(content_length)? {
212+
return Err(Error::NoSpace(format!(
213+
"not enough space to store the persistent cache task: content_length={}",
214+
content_length
215+
)));
219216
}
220217

221218
self.storage.download_task_started(

0 commit comments

Comments
 (0)