Skip to content

Commit

Permalink
reflink_or_copy instead of std::fs::copy (#32)
Browse files Browse the repository at this point in the history
Many modern file systems allow COPY to be implemented in a way
that avoids duplication, similar to a hard link but allowing the
contents of the files to diverge as a result of a later write.
  • Loading branch information
dr-m authored Aug 20, 2024
1 parent f36e3ad commit b010148
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ default = ["localfs", "memfs"]
actix-compat = [ "actix-web" ]
warp-compat = [ "warp", "hyper" ]
all = [ "actix-compat", "warp-compat" ]
localfs = ["libc", "lru", "parking_lot"]
localfs = ["libc", "lru", "parking_lot", "reflink-copy"]
memfs = ["libc"]

[[example]]
Expand Down Expand Up @@ -62,6 +62,7 @@ xmltree = "0.10.0"
hyper = { version = "1.1.0", optional = true }
warp = { version = "0.3.0", optional = true, default-features = false }
actix-web = { version = "4.0.0-beta.15", optional = true }
reflink-copy = { version = "0.1.14", optional = true }

[dev-dependencies]
clap = { version = "4.0.0", features = ["derive"] }
Expand Down
3 changes: 2 additions & 1 deletion src/localfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use pin_utils::pin_mut;
use tokio::task;

use libc;
use reflink_copy::reflink_or_copy;

use crate::davpath::DavPath;
use crate::fs::*;
Expand Down Expand Up @@ -444,7 +445,7 @@ impl DavFileSystem for LocalFs {
let path_to = self.fspath(to);

match self
.blocking(move || std::fs::copy(path_from, path_to))
.blocking(move || reflink_or_copy(path_from, path_to))
.await
{
Ok(_) => Ok(()),
Expand Down

0 comments on commit b010148

Please sign in to comment.