Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-sectorbuilder
Commits
d9cc96c5
Commit
d9cc96c5
authored
Jan 23, 2020
by
Łukasz Magiera
Browse files
More correct cache cleanup in PreCommit
parent
99304d84
Changes
1
Hide whitespace changes
Inline
Side-by-side
sectorbuild_cgo.go
View file @
d9cc96c5
...
...
@@ -5,6 +5,7 @@ package sectorbuilder
import
(
"context"
"io"
"io/ioutil"
"os"
"sync/atomic"
...
...
@@ -142,15 +143,16 @@ func (sb *SectorBuilder) SealPreCommit(ctx context.Context, sectorID uint64, tic
return
RawSealPreCommitOutput
{},
xerrors
.
Errorf
(
"getting cache dir: %w"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
cacheDir
);
!
os
.
IsNotExist
(
err
)
{
cached
,
err
:=
ioutil
.
ReadDir
(
cacheDir
)
if
err
!=
nil
{
return
RawSealPreCommitOutput
{},
xerrors
.
Errorf
(
"reading cache dir: %w"
,
err
)
}
if
len
(
cached
)
>
0
{
// TODO: can we read t_aux or p_aux to check if we have the correct thing sealed here already?
// (need to check ticket)
if
err
!=
nil
{
return
RawSealPreCommitOutput
{},
xerrors
.
Errorf
(
"stat cache dir: %w"
,
err
)
}
log
.
Warnf
(
"precommit: found cache dir %s, cleaning up"
,
cacheDir
)
log
.
Warnf
(
"precommit: cache dir %s contains files %v, cleaning up"
,
cacheDir
,
cached
)
if
err
:=
os
.
RemoveAll
(
cacheDir
);
err
!=
nil
{
return
RawSealPreCommitOutput
{},
xerrors
.
Errorf
(
"removing cache dir %s: %w"
,
cacheDir
,
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment