Skip to content

Commit 76114a7

Browse files
committed
* remove atomic
1 parent 47b796e commit 76114a7

File tree

3 files changed

+10
-69
lines changed

3 files changed

+10
-69
lines changed

atomic/file_unix.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

atomic/file_windows.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

decompression.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package embeddedpostgres
22

33
import (
44
"archive/tar"
5+
"errors"
56
"fmt"
67
"io"
78
"os"
89
"path/filepath"
10+
"syscall"
911

10-
"github.com/fergusstrange/embedded-postgres/atomic"
1112
"github.com/xi2/xz"
1213
)
1314

@@ -97,7 +98,14 @@ func decompressTarXz(tarReader func(*xz.Reader) (func() (*tar.Header, error), fu
9798
continue
9899
}
99100

100-
if err := atomic.Rename(targetPath, finalPath); err != nil {
101+
if err := os.Rename(targetPath, finalPath); err != nil {
102+
// if the error is due to syscall.EEXIST then this is most likely windows, and a race condition with
103+
// multiple downloads of the file. We assume that the existing file is the correct one and ignore the
104+
// error
105+
if errors.Is(err, syscall.EEXIST) {
106+
return nil
107+
}
108+
101109
return errorExtractingPostgres(err)
102110
}
103111

0 commit comments

Comments
 (0)