Updated clone.go to support file not found on target

This commit is contained in:
mitch 2021-12-31 02:13:31 -05:00
parent 41a3e3086a
commit e77ab09050
2 changed files with 5 additions and 2 deletions

1
.gitignore vendored
View File

@ -103,3 +103,4 @@ $RECYCLE.BIN/
.vscode/*
.idea
/diskutil

View File

@ -25,8 +25,10 @@ func clone(cloneBs int, cloneSource string, cloneTarget string) {
fSource, err := os.Open(cloneSource)
defer fSource.Close()
errorHandler(err)
//todo add file not found handling
fTarget, err := os.OpenFile(cloneTarget, os.O_WRONLY, 0644)
if os.IsNotExist(err) {
fTarget, err = os.Create(cloneTarget)
}
defer fTarget.Close()
errorHandler(err)
//todo progress indicator