mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-08-16 18:03:55 +08:00
feat: show upload progress for batch file tasks (#228)
* feat: show upload progress for file tasks * feat: show upload progress for batch file tasks * style: distinguish download and upload phases * style: mark successful task completion * fix: preserve storage save error context * fix: serialize single-file progress updates * fix: stabilize batch upload progress reporting Correct batch upload totals, completion state, actual file sizes, and synchronized progress snapshots. Add regression coverage for concurrent updates and phase transitions. * feat: show per-file transfer progress Format single-file and batch download and upload states with Telegram entities, blockquotes, speeds, transferred sizes, progress bars, concise counters, and accurate confirmation handling. Cover upload retries plus final, error, and cancellation messages with regression tests. * chore: remove transfer progress tests * test: restore critical transfer progress coverage * test: cover interleaved batch transfers * fix: declare progress styles in locale templates
This commit is contained in:
@@ -38,6 +38,31 @@ type StorageBatchSaver interface {
|
||||
SaveBatch(ctx context.Context, items []storagetypes.BatchItem) error
|
||||
}
|
||||
|
||||
// StorageBatchProgressSaver reports confirmed upload progress for each item in
|
||||
// a logical batch. The item index matches the items slice passed to
|
||||
// SaveBatchWithProgress.
|
||||
type StorageBatchProgressSaver interface {
|
||||
StorageBatchSaver
|
||||
SaveBatchWithProgress(
|
||||
ctx context.Context,
|
||||
items []storagetypes.BatchItem,
|
||||
onProgress func(index int, uploaded, total int64),
|
||||
) error
|
||||
}
|
||||
|
||||
// StorageProgressSaver reports bytes after the backend has accepted them for
|
||||
// upload. Backends with native progress support should implement this instead
|
||||
// of relying on progress inferred from reads of the input stream.
|
||||
type StorageProgressSaver interface {
|
||||
Storage
|
||||
SaveWithProgress(
|
||||
ctx context.Context,
|
||||
reader io.Reader,
|
||||
storagePath string,
|
||||
onProgress func(uploaded, total int64),
|
||||
) error
|
||||
}
|
||||
|
||||
// StorageListable 表示支持列举目录内容的存储
|
||||
type StorageListable interface {
|
||||
Storage
|
||||
@@ -52,6 +77,9 @@ type StorageReadable interface {
|
||||
|
||||
var Storages = make(map[string]Storage)
|
||||
|
||||
var _ StorageProgressSaver = (*telegram.Telegram)(nil)
|
||||
var _ StorageBatchProgressSaver = (*telegram.Telegram)(nil)
|
||||
|
||||
type StorageConstructor func() Storage
|
||||
|
||||
var storageConstructors = map[storenum.StorageType]StorageConstructor{
|
||||
|
||||
Reference in New Issue
Block a user