Merge pull request #24 from anytypeio/files

file fixes: rpcstore context listen
This commit is contained in:
Sergey Cherepanov 2022-12-26 19:13:43 +03:00 committed by GitHub
commit ac018be8b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,7 +91,11 @@ func (c *client) opLoop(ctx context.Context) {
} }
if err != nil { if err != nil {
t.err = err t.err = err
t.ready <- t select {
case t.ready <- t:
case <-t.ctx.Done():
case <-ctx.Done():
}
} }
} }
} }
@ -107,7 +111,13 @@ func (c *client) delete(ctx context.Context, t *task) (err error) {
}); err != nil { }); err != nil {
return rpcerr.Unwrap(err) return rpcerr.Unwrap(err)
} }
t.ready <- t select {
case t.ready <- t:
case <-t.ctx.Done():
return t.ctx.Err()
case <-ctx.Done():
return ctx.Err()
}
c.stat.UpdateLastUsage() c.stat.UpdateLastUsage()
return return
} }
@ -128,6 +138,8 @@ func (c *client) put(ctx context.Context, t *task) (err error) {
log.Debug("put cid", zap.String("cid", t.cid.String())) log.Debug("put cid", zap.String("cid", t.cid.String()))
select { select {
case t.ready <- t: case t.ready <- t:
case <-t.ctx.Done():
return t.ctx.Err()
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
} }