mirror of
https://github.com/tiennm99/telegram-exporter.git
synced 2026-10-11 03:13:49 +00:00
pikpak commits an upload as a server-side async task, and rclone polls that task only as long as its low-level retries last. A task still in PHASE_TYPE_PENDING when that budget runs out is reported as "can't verify the task is completed" — and checking the live archive ten minutes later, those tasks had not committed: the objects were simply absent. The transfer itself was fine; only the confirmation timed out. Abandoning the file meant re-downloading it from Telegram on the next pass, which for this archive can be two gigabytes, so a run against a slow remote paid for the same bytes repeatedly. The staged copy is still on disk when a move fails — rclone says so in the same breath — so another attempt costs seconds instead. Every attempt after the first checks the remote before re-uploading. A pending task may have committed during the backoff, and pikpak allows two files under one name, so re-uploading blind is how one file becomes two — which verification then reports as an ambiguous basename on every future run. rclone's log now goes through the renderer. It writes to stderr on its own schedule, so its error lines were landing mid-redraw and shredding the display exactly when there was most to read. Also: "capped at uncapped" now reads "uncapped", and the ETA column fits the three-digit hour counts a slow remote produces.
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package report
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
rclonelog "github.com/rclone/rclone/fs/log"
|
|
)
|
|
|
|
// CaptureRcloneLog routes rclone's own log lines to w.
|
|
//
|
|
// rclone writes to stderr through its private logger on its own schedule
|
|
// (fs/log/slog.go:43 installs a stderr handler via fs.SetLogger). While bars are
|
|
// drawing, that lands mid-redraw and shreds the display — a run hitting a series
|
|
// of pikpak commit failures became unreadable. Pointing the logger at the
|
|
// progress writer makes each line scroll above the bars instead.
|
|
//
|
|
// The returned function puts the logger back on stderr. rclone exposes no getter
|
|
// for the current handler, so this restores the default rather than whatever was
|
|
// there before; nothing in this program installs a third one.
|
|
func CaptureRcloneLog(ctx context.Context, w io.Writer) (restore func()) {
|
|
level := fs.LogLevelToSlog(fs.GetConfig(ctx).LogLevel)
|
|
fs.SetLogger(rclonelog.NewOutputHandler(w, &slog.HandlerOptions{Level: level}, 0))
|
|
return func() {
|
|
fs.SetLogger(rclonelog.NewOutputHandler(os.Stderr, &slog.HandlerOptions{Level: level}, 0))
|
|
}
|
|
}
|