File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
management/server/geolocation Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package geolocation
3
3
import (
4
4
"encoding/csv"
5
5
"fmt"
6
+ "io"
6
7
"net/url"
7
8
"os"
8
9
"path"
@@ -35,7 +36,7 @@ func loadGeolocationDatabases(dataDir string) error {
35
36
if err := decompressTarGzFile (src , dst ); err != nil {
36
37
return err
37
38
}
38
- return os . Rename (path .Join (dst , MMDBFileName ), path .Join (dataDir , MMDBFileName ))
39
+ return copyFile (path .Join (dst , MMDBFileName ), path .Join (dataDir , MMDBFileName ))
39
40
}
40
41
if err := loadDatabase (
41
42
geoLiteCitySha256TarURL ,
@@ -185,3 +186,25 @@ func getDatabaseFileName(urlStr string) string {
185
186
fileName := fmt .Sprintf ("%s.%s" , path .Base (u .Path ), ext )
186
187
return fileName
187
188
}
189
+
190
+ // copyFile performs a file copy operation from the source file to the destination.
191
+ func copyFile (src string , dst string ) error {
192
+ srcFile , err := os .Open (src )
193
+ if err != nil {
194
+ return err
195
+ }
196
+ defer srcFile .Close ()
197
+
198
+ dstFile , err := os .Create (dst )
199
+ if err != nil {
200
+ return err
201
+ }
202
+ defer dstFile .Close ()
203
+
204
+ _ , err = io .Copy (dstFile , srcFile )
205
+ if err != nil {
206
+ return err
207
+ }
208
+
209
+ return nil
210
+ }
You can’t perform that action at this time.
0 commit comments