Skip to content

Commit

Permalink
create plugin files hard link to save resources
Browse files Browse the repository at this point in the history
  • Loading branch information
asiyani committed Dec 30, 2024
1 parent 49b6dce commit 6193271
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions sysutil/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sysutil
import (
"context"
"fmt"
"io"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -42,20 +41,8 @@ func CopyFile(src, dst string, withReplace bool) error {
}
}

if srcFileDescriptor, err = os.Open(src); err != nil {
return err
}
defer srcFileDescriptor.Close()

if dstFileDescriptor, err = os.Create(dst); err != nil {
return err
}
defer dstFileDescriptor.Close()

if _, err = io.Copy(dstFileDescriptor, srcFileDescriptor); err != nil {
return err
}
return os.Chmod(dst, srcInfo.Mode())
// create hard link to save cpu/mem/disk io
return os.Link(src, dst)
}

// CopyDir copies a dir recursively
Expand Down

0 comments on commit 6193271

Please sign in to comment.