Skip to content

fs::copy fails copying '.git' dir from Linux to Windows(SMB) #131026

Closed as not planned
@TobisLee

Description

@TobisLee

I tried to copy a git repository from Linux host to Windows host using yazi. And I noticed that there are some files in .git dir are copied failed. The error is permission denied. I reported to yazi (see sxyazi/yazi#1703). But it seems yazi just call the std::fs::copy to copy files. And I tried the following code:

use std::fs;

fn main() {
    fs::copy(
        "/home/xxx/.git/objects/pack/pack-d2e6xxxc2.idx",
        "/win-share/pack-d2e6xxxc2.idx").unwrap();
}

I expected to see this happen:
File pack-d2e6xxxc2.idx is copied to Windows directory.

Instead, this happened:

Error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }

Meta

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:1654:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:1077:23
   4: fs_copy::main
             at ./src/main.rs:4:5
   5: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions