mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
remote: Expose CopyFile
This commit is contained in:
parent
c24123ff8a
commit
93f7d86546
@ -381,7 +381,7 @@ func Persist(r io.Reader) error {
|
|||||||
backupPath := filepath.Join(cwd, LocalDirectory, BackupHiddenStateFile)
|
backupPath := filepath.Join(cwd, LocalDirectory, BackupHiddenStateFile)
|
||||||
|
|
||||||
// Backup the old file if it exists
|
// Backup the old file if it exists
|
||||||
if err := copyFile(statePath, backupPath); err != nil {
|
if err := CopyFile(statePath, backupPath); err != nil {
|
||||||
return fmt.Errorf("Failed to backup state file '%s' to '%s': %v", statePath, backupPath, err)
|
return fmt.Errorf("Failed to backup state file '%s' to '%s': %v", statePath, backupPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,9 +401,9 @@ func Persist(r io.Reader) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyFile is used to copy from a source file if it exists to a destination.
|
// CopyFile is used to copy from a source file if it exists to a destination.
|
||||||
// This is used to create a backup of the state file.
|
// This is used to create a backup of the state file.
|
||||||
func copyFile(src, dst string) error {
|
func CopyFile(src, dst string) error {
|
||||||
srcFH, err := os.Open(src)
|
srcFH, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user