From 1639aafa622b89263864870cf1397f6d3440e5f7 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 4 Apr 2021 10:43:19 +0200 Subject: [PATCH] sync: remove duplication when setting path to temporary file --- cmd/safcm-remote/sync/files.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/safcm-remote/sync/files.go b/cmd/safcm-remote/sync/files.go index 12508ce..158b553 100644 --- a/cmd/safcm-remote/sync/files.go +++ b/cmd/safcm-remote/sync/files.go @@ -328,16 +328,16 @@ reopen: } dir := filepath.Dir(file.Path) - base := filepath.Base(file.Path) + // Create hidden file which should be ignored by most other tools and + // thus not affect anything during creation + base := "." + filepath.Base(file.Path) var tmpPath string switch file.Mode.Type() { case 0: // regular file debugf("creating temporary file %q", - filepath.Join(dir, "."+base+"*")) - // Create hidden file which should be ignored by most other - // tools and thus not affect anything during creation - newFh, err := os.CreateTemp(dir, "."+base) + filepath.Join(dir, base+"*")) + newFh, err := os.CreateTemp(dir, base) if err != nil { return err } @@ -381,7 +381,7 @@ reopen: // Similar to os.CreateTemp() but for symlinks which we cannot // open as file tmpPath = filepath.Join(dir, - "."+base+strconv.Itoa(rand.Int())) + base+strconv.Itoa(rand.Int())) debugf("creating temporary symlink %q", tmpPath) err := os.Symlink(string(file.Data), tmpPath) if err != nil { -- 2.44.1