package downloader
import (
"context"
"github.com/go-faster/errors"
"github.com/gotd/td/tg"
)
var errHashesNotSupported = errors .New ("this schema does not support hashes fetch" )
type web struct {
client Client
retryHandler RetryHandler
location tg .InputWebFileLocationClass
}
var _ schema = web {}
func (w web ) reportRetry (operation string , attempt int , err error ) {
if attempt < 1 || err == nil || w .retryHandler == nil {
return
}
w .retryHandler (RetryEvent {
Operation : operation ,
Attempt : attempt ,
Err : err ,
})
}
func (w web ) Chunk (ctx context .Context , offset int64 , limit int ) (chunk , error ) {
file , err := w .client .UploadGetWebFile (ctx , &tg .UploadGetWebFileRequest {
Location : w .location ,
Offset : int (offset ),
Limit : limit ,
})
if err != nil {
return chunk {}, err
}
return chunk {data : file .Bytes , tag : file .FileType }, nil
}
func (w web ) Hashes (ctx context .Context , offset int64 ) ([]tg .FileHash , error ) {
return nil , errHashesNotSupported
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .