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

3
.gitignore vendored
View File

@ -102,4 +102,5 @@ $RECYCLE.BIN/
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
.vscode/* .vscode/*
.idea .idea
/diskutil

View File

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