Add context cancellation support to Scan
This commit is contained in:
parent
b55ae961c8
commit
1ae384b6f6
@ -192,12 +192,19 @@ func (m *manifest) addFile(p string, fi fs.FileInfo, sfsIndex int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *manifest) Scan() error {
|
func (m *manifest) Scan() error {
|
||||||
// FIXME scan and whatever function does the hashing should take ctx
|
|
||||||
for idx, sfs := range m.sourceFS {
|
for idx, sfs := range m.sourceFS {
|
||||||
if sfs == nil {
|
if sfs == nil {
|
||||||
return errors.New("invalid source fs")
|
return errors.New("invalid source fs")
|
||||||
}
|
}
|
||||||
e := afero.Walk(sfs, "/", func(p string, info fs.FileInfo, err error) error {
|
e := afero.Walk(sfs, "/", func(p string, info fs.FileInfo, err error) error {
|
||||||
|
// Check for context cancellation
|
||||||
|
if m.ctx != nil {
|
||||||
|
select {
|
||||||
|
case <-m.ctx.Done():
|
||||||
|
return m.ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
return m.addFile(p, info, idx)
|
return m.addFile(p, info, idx)
|
||||||
})
|
})
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user