Feat: cancel upload session in slave node

This commit is contained in:
HFO4
2022-03-13 16:18:39 +08:00
parent effbc8607e
commit 0650684dd9
7 changed files with 84 additions and 110 deletions

View File

@@ -18,7 +18,7 @@ type ConstantBackoff struct {
func (c *ConstantBackoff) Next() bool {
c.tried++
if c.tried >= c.Max {
if c.tried > c.Max {
return false
}

View File

@@ -49,7 +49,7 @@ func (c *ChunkGroup) Process(processor ChunkProcessFunc) error {
err := processor(c, io.LimitReader(c.file, int64(c.chunkSize)))
if err != nil {
if err != context.Canceled && c.file.Seekable() && c.backoff.Next() {
if _, seekErr := c.file.Seek(c.Start(), io.SeekStart); err != nil {
if _, seekErr := c.file.Seek(c.Start(), io.SeekStart); seekErr != nil {
return fmt.Errorf("failed to seek back to chunk start: %w, last error: %w", seekErr, err)
}