From e77ab090502a84f657a41fec5a409e446a164483 Mon Sep 17 00:00:00 2001 From: mitch Date: Fri, 31 Dec 2021 02:13:31 -0500 Subject: [PATCH] Updated clone.go to support file not found on target --- .gitignore | 3 ++- clone.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 085f9fd..fea1400 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,5 @@ $RECYCLE.BIN/ # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) .vscode/* -.idea \ No newline at end of file +.idea +/diskutil diff --git a/clone.go b/clone.go index d729b20..7e962b2 100644 --- a/clone.go +++ b/clone.go @@ -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