Skip to content

Commit 8e8f707

Browse files
committed
substitute a pure copy for rename to handle cross device renames
1 parent 524a515 commit 8e8f707

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pkg/gomason/gomason.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
// VERSION is the current gomason version
17-
const VERSION = "2.11.0"
17+
const VERSION = "2.11.1"
1818

1919
// METADATA_FILENAME The default gomason metadata file name
2020
const METADATA_FILENAME = "metadata.json"
@@ -277,21 +277,33 @@ func CollectFileAndSignature(cwd string, filename string) (err error) {
277277

278278
log.Printf("[DEBUG] Collecting Binaries and Signatures (if signing)")
279279

280-
err = os.Rename(filename, binaryDestinationPath)
280+
contents, err := os.ReadFile(filename)
281281
if err != nil {
282-
err = errors.Wrap(err, fmt.Sprintf("failed to collect file %q", filename))
282+
err = errors.Wrapf(err, "failed reading file %q", filename)
283+
return err
284+
}
285+
286+
err = os.WriteFile(binaryDestinationPath, contents, 0644)
287+
if err != nil {
288+
err = errors.Wrapf(err, "failed writing file %s", binaryDestinationPath)
283289
return err
284290
}
285291

286292
sigName := fmt.Sprintf("%s.asc", filepath.Base(filename))
287293
if _, err := os.Stat(sigName); !os.IsNotExist(err) {
288294
signatureDestinationPath := fmt.Sprintf("%s/%s", cwd, sigName)
295+
contents, err := os.ReadFile(filename)
296+
if err != nil {
297+
err = errors.Wrapf(err, "failed reading file %q", filename)
298+
return err
299+
}
289300

290-
err = os.Rename(sigName, signatureDestinationPath)
301+
err = os.WriteFile(signatureDestinationPath, contents, 0644)
291302
if err != nil {
292-
err = errors.Wrap(err, fmt.Sprintf("failed to collect signature %q", sigName))
303+
err = errors.Wrapf(err, "failed writing file %s", signatureDestinationPath)
293304
return err
294305
}
306+
295307
}
296308

297309
return err

0 commit comments

Comments
 (0)