aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-08-13 13:08:23 -0400
committerBen Burwell <ben@benburwell.com>2019-08-13 13:08:23 -0400
commit2fde66440ea282532bb1a8e0380e32d331302e39 (patch)
tree8ba7cad6de673a60493f9b87db3a489ded66821b
parentb8dd7dae42e783f2236f889d276e66bedb182837 (diff)
truncate files when writing
-rw-r--r--adopt.go2
-rw-r--r--apply.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/adopt.go b/adopt.go
index 9be0a77..0f900eb 100644
--- a/adopt.go
+++ b/adopt.go
@@ -30,7 +30,7 @@ func adoptFile(name string) error {
return err
}
defer from.Close()
- to, err := os.OpenFile(toPath, os.O_CREATE|os.O_WRONLY, 0600)
+ to, err := os.OpenFile(toPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
if err != nil {
return err
}
diff --git a/apply.go b/apply.go
index 7ea5bf9..eaa528a 100644
--- a/apply.go
+++ b/apply.go
@@ -42,7 +42,7 @@ func applyFile(name string) error {
if err = os.MkdirAll(filepath.Dir(d), 0700); err != nil {
return err
}
- out, err := os.OpenFile(d, os.O_CREATE|os.O_WRONLY, 0600)
+ out, err := os.OpenFile(d, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)
if err != nil {
return err
}