Updated clone.go to support file not found on target
This commit is contained in:
parent
41a3e3086a
commit
e77ab09050
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
||||||
|
4
clone.go
4
clone.go
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user