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

Function RenameFileCopyPermissions

tools/filetools.go:71–87  ·  view source on GitHub ↗

RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if necessary and also copying the permissions of destfile if it already exists

(srcfile, destfile string)

Source from the content-addressed store, hash-verified

69// RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if
70// necessary and also copying the permissions of destfile if it already exists
71func RenameFileCopyPermissions(srcfile, destfile string) error {
72 info, err := os.Stat(destfile)
73 if os.IsNotExist(err) {
74 // no original file
75 } else if err != nil {
76 return err
77 } else {
78 if err := os.Chmod(srcfile, info.Mode()); err != nil {
79 return errors.New(tr.Tr.Get("can't set filemode on file %q: %v", srcfile, err))
80 }
81 }
82
83 if err := RobustRename(srcfile, destfile); err != nil {
84 return errors.New(tr.Tr.Get("cannot replace %q with %q: %v", destfile, srcfile, err))
85 }
86 return nil
87}
88
89// CleanPaths splits the given `paths` argument by the delimiter argument, and
90// then "cleans" that path according to the path.Clean function (see

Callers 3

downloadMethod · 0.92
doDownloadMethod · 0.92
DoTransferMethod · 0.92

Calls 4

NewFunction · 0.92
ModeMethod · 0.80
RobustRenameFunction · 0.70
GetMethod · 0.65

Tested by

no test coverage detected