From 87d178e984b97142db10648a33f34ef1ee39d392 Mon Sep 17 00:00:00 2001 From: Andy Cooper Date: Mon, 24 Sep 2018 16:55:17 -0400 Subject: [PATCH] Prevent file from being overwritten if it exists --- airflow/airflow.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/airflow/airflow.go b/airflow/airflow.go index bf7e68739..bd695ffb4 100644 --- a/airflow/airflow.go +++ b/airflow/airflow.go @@ -43,11 +43,15 @@ func initFiles(root string, files map[string]string) error { fullpath := filepath.Join(root, file) // Move on if already exists - _, err := fileutil.Exists(fullpath) + fileExist, err := fileutil.Exists(fullpath) if err != nil { return errors.Wrapf(err, "failed to check existence of '%s'", fullpath) } + if fileExist { + continue + } + // Write files out if err := fileutil.WriteStringToFile(fullpath, content); err != nil { return errors.Wrapf(err, "failed to create file '%s'", fullpath)