mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-11 02:27:05 +02:00
Initial implementation of unified export/import progress
Both export and import progress get updated over a unified channel. Most importantly this allows updating the import total from latest export results.
This commit is contained in:
parent
1f48abc284
commit
b8e6ccffdb
18 changed files with 369 additions and 194 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
|
||||
Copyright © 2023-2025 Philipp Wolfer <phw@uploadedlobster.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -209,11 +209,25 @@ func (i *ImportResult) Log(t LogEntryType, msg string) {
|
|||
})
|
||||
}
|
||||
|
||||
type TransferProgress struct {
|
||||
Export *Progress
|
||||
Import *Progress
|
||||
}
|
||||
|
||||
func (p TransferProgress) FromImportResult(result ImportResult, completed bool) TransferProgress {
|
||||
importProgress := Progress{
|
||||
Completed: completed,
|
||||
}.FromImportResult(result)
|
||||
p.Import = &importProgress
|
||||
return p
|
||||
}
|
||||
|
||||
type Progress struct {
|
||||
Total int64
|
||||
Elapsed int64
|
||||
Completed bool
|
||||
Aborted bool
|
||||
TotalItems int
|
||||
Total int64
|
||||
Elapsed int64
|
||||
Completed bool
|
||||
Aborted bool
|
||||
}
|
||||
|
||||
func (p Progress) FromImportResult(result ImportResult) Progress {
|
||||
|
@ -222,13 +236,11 @@ func (p Progress) FromImportResult(result ImportResult) Progress {
|
|||
return p
|
||||
}
|
||||
|
||||
func (p Progress) Complete() Progress {
|
||||
func (p *Progress) Complete() {
|
||||
p.Elapsed = p.Total
|
||||
p.Completed = true
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Progress) Abort() Progress {
|
||||
func (p *Progress) Abort() {
|
||||
p.Aborted = true
|
||||
return p
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue