Files
restic/internal/restorer/progress.go
T
Michael Eischer 2f31cde517 internal/restorer: invert dependency direction to ui/restorer
The restorer imported ui/restorer which leaks ui logic into the restorer
core. Swap the direction by letting the restorer use a ProgressReporter
interface + associated constants.
2026-06-20 17:49:20 +02:00

39 lines
1.1 KiB
Go

package restorer
type ItemAction string
// Constants for the different CompleteItem actions.
const (
ActionDirRestored ItemAction = "dir restored"
ActionFileRestored ItemAction = "file restored"
ActionFileUpdated ItemAction = "file updated"
ActionFileUnchanged ItemAction = "file unchanged"
ActionOtherRestored ItemAction = "other restored"
ActionDeleted ItemAction = "deleted"
)
// ProgressReporter reports restore progress.
type ProgressReporter interface {
AddFile(size uint64)
AddProgress(name string, action ItemAction, bytesWrittenPortion, bytesTotal uint64)
AddSkippedFile(name string, size uint64)
ReportDeletion(name string)
}
type noopProgressReporter struct{}
var _ ProgressReporter = (*noopProgressReporter)(nil)
func (noopProgressReporter) AddFile(uint64) {}
func (noopProgressReporter) AddProgress(string, ItemAction, uint64, uint64) {
}
func (noopProgressReporter) AddSkippedFile(string, uint64) {}
func (noopProgressReporter) ReportDeletion(string) {}
func progressOrNoop(p ProgressReporter) ProgressReporter {
if p == nil {
return noopProgressReporter{}
}
return p
}