Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Khải <[email protected]>
  • Loading branch information
nachoaldamav and KSXGitHub authored Nov 2, 2023
1 parent c3c6f2b commit 37e9d1f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#[macro_use]
extern crate napi_derive;
use copy_on_write::reflink_file_sync as reflink;
use copy_on_write::reflink_file_sync;
use napi::{bindgen_prelude::AsyncTask, Env, Error, JsNumber, Result, Task};
use std::path::PathBuf;

Expand All @@ -25,7 +25,7 @@ impl Task for AsyncReflink {
Error::from_reason("Invalid UTF-8 sequence in destination path".to_string())
})?;

match reflink(src_str, dst_str) {
match reflink_file_sync(src_str, dst_str) {
Ok(_) => {
Ok(())
},
Expand Down Expand Up @@ -54,7 +54,7 @@ pub fn reflink_task(src: String, dst: String) -> AsyncTask<AsyncReflink> {
// Sync version
#[napi(js_name = "reflinkFileSync")]
pub fn reflink_sync(env: Env, src: String, dst: String) -> Result<JsNumber> {
match reflink(&src, &dst) {
match reflink_file_sync(src, dst) {
Ok(_) => Ok(env.create_int32(0)?),
Err(err) => Err(Error::from_reason(format!(
"{}, reflink '{}' -> '{}'",
Expand All @@ -73,15 +73,15 @@ pub fn test_pyc_file() {
let dst_path = std::path::Path::new(dst);

// Remove the destination file if it already exists
if dst_path.exists() {
if dst_path.try_exists().unwrap() {
std::fs::remove_file(&dst).unwrap();
}

// Run the reflink operation
let result = reflink(&src, &dst);
let result = reflink_file_sync(src, dst);
assert!(result.is_ok());

println!("Reflinked '{}' -> '{}'", src, dst);
println!("Reflinked {src:?} -> {dst:?}");

// Further validation: compare the contents of both files to make sure they are identical
let src_contents = std::fs::read(&src).expect("Failed to read source file");
Expand Down

0 comments on commit 37e9d1f

Please sign in to comment.