MCPcopy
hub / github.com/git-lfs/git-lfs / CheckCloneFileSupported

Function CheckCloneFileSupported

tools/util_linux.go:17–41  ·  view source on GitHub ↗

CheckCloneFileSupported runs explicit test of clone file on supplied directory. This function creates some (src and dst) file in the directory and remove after test finished. If check failed (e.g. directory is read-only), returns err.

(dir string)

Source from the content-addressed store, hash-verified

15//
16// If check failed (e.g. directory is read-only), returns err.
17func CheckCloneFileSupported(dir string) (supported bool, err error) {
18 src, err := os.CreateTemp(dir, "src")
19 if err != nil {
20 return false, err
21 }
22 defer func() {
23 src.Close()
24 os.Remove(src.Name())
25 }()
26
27 dst, err := os.CreateTemp(dir, "dst")
28 if err != nil {
29 return false, err
30 }
31 defer func() {
32 dst.Close()
33 os.Remove(dst.Name())
34 }()
35
36 if ok, err := CloneFile(dst, src); err != nil {
37 return false, err
38 } else {
39 return ok, nil
40 }
41}
42
43func CloneFile(writer io.Writer, reader io.Reader) (bool, error) {
44 fdst, fdstFound := writer.(*os.File)

Callers 5

dedupTestCommandFunction · 0.92
dedupCommandFunction · 0.92
TestMethodExistsFunction · 0.70
TestCloneFileFunction · 0.70

Calls 4

CloneFileFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.65
RemoveMethod · 0.45

Tested by 3

TestMethodExistsFunction · 0.56
TestCloneFileFunction · 0.56