Skip to content

Commit

Permalink
Fix: mkdir before copying file for local chunk manager (#401)
Browse files Browse the repository at this point in the history
Signed-off-by: jason.jin <[email protected]>
Co-authored-by: jason.jin <[email protected]>
  • Loading branch information
wayblink and jason-ltc authored Aug 20, 2024
1 parent 7250521 commit 2bc73b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/storage/local_chunk_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,20 @@ func CopyDir(source string, dest string) (err error) {
}

func CopyFile(source string, dest string) (err error) {

// get properties of source parent dir
sourceParentDir := filepath.Dir(source)
sourceParentDirInfo, err := os.Stat(sourceParentDir)
if err != nil {
return err
}
// create dest parent dir
destParentDir := filepath.Dir(dest)
err = os.MkdirAll(destParentDir, sourceParentDirInfo.Mode())
if err != nil {
return err
}

sourcefile, err := os.Open(source)
if err != nil {
return err
Expand Down

0 comments on commit 2bc73b5

Please sign in to comment.