mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-20 17:31:11 +00:00
etl: create a subfolder in datadir
for temp files. (#965)
This commit is contained in:
parent
2facf92533
commit
9b81829616
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common"
|
"github.com/ledgerwatch/turbo-geth/common"
|
||||||
@ -31,6 +32,16 @@ func FlushToDisk(encoder Encoder, currentKey []byte, b Buffer, datadir string) (
|
|||||||
if b.Len() == 0 {
|
if b.Len() == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
// if we are going to create files in the system temp dir, we don't need any
|
||||||
|
// subfolders.
|
||||||
|
if datadir != "" {
|
||||||
|
// the folder name stays the same and shared between ETL runs, so we don't need to remove it.
|
||||||
|
// it actually can make debugging more tricky in case we leak some open files.
|
||||||
|
datadir = path.Join(datadir, "etl-temp")
|
||||||
|
if err := os.MkdirAll(datadir, 0755); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
bufferFile, err := ioutil.TempFile(datadir, "tg-sync-sortable-buf")
|
bufferFile, err := ioutil.TempFile(datadir, "tg-sync-sortable-buf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user