mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
remove only etl-tmp content, but not dir itself #4816
This commit is contained in:
parent
b231856c1c
commit
9e371fef5c
@ -149,7 +149,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpdir := stack.Config().Dirs.Tmp
|
tmpdir := stack.Config().Dirs.Tmp
|
||||||
if err := os.RemoveAll(tmpdir); err != nil { // clean it on startup
|
if err := RemoveContents(tmpdir); err != nil { // clean it on startup
|
||||||
return nil, fmt.Errorf("clean tmp dir: %s, %w", tmpdir, err)
|
return nil, fmt.Errorf("clean tmp dir: %s, %w", tmpdir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,3 +912,23 @@ func (s *Ethereum) SentryCtx() context.Context {
|
|||||||
func (s *Ethereum) SentryControlServer() *sentry.MultiClient {
|
func (s *Ethereum) SentryControlServer() *sentry.MultiClient {
|
||||||
return s.sentriesClient
|
return s.sentriesClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveContents is like os.RemoveAll, but preserve dir itself
|
||||||
|
func RemoveContents(dir string) error {
|
||||||
|
d, err := os.Open(dir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer d.Close()
|
||||||
|
names, err := d.Readdirnames(-1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, name := range names {
|
||||||
|
err = os.RemoveAll(filepath.Join(dir, name))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user