mirror of
https://github.com/restic/restic.git
synced 2025-03-09 00:00:02 +01:00
Add progress calculation support for ADS
This commit is contained in:
parent
400b0a3958
commit
27e165f43f
3 changed files with 41 additions and 2 deletions
|
@ -4,6 +4,9 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
|
@ -86,8 +89,15 @@ func (p *Progress) AddFile(size uint64) {
|
|||
p.s.AllBytesTotal += size
|
||||
}
|
||||
|
||||
// AddSize starts tracking a new file with the given size
|
||||
func (p *Progress) AddSize(size uint64) {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
p.s.AllBytesTotal += size
|
||||
}
|
||||
|
||||
// AddProgress accumulates the number of bytes written for a file
|
||||
func (p *Progress) AddProgress(name string, action ItemAction, bytesWrittenPortion uint64, bytesTotal uint64) {
|
||||
func (p *Progress) AddProgress(name string, action ItemAction, bytesWrittenPortion uint64, bytesTotal uint64, attrs map[restic.GenericAttributeType]json.RawMessage) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
|
@ -105,7 +115,7 @@ func (p *Progress) AddProgress(name string, action ItemAction, bytesWrittenPorti
|
|||
p.s.AllBytesWritten += bytesWrittenPortion
|
||||
if entry.bytesWritten == entry.bytesTotal {
|
||||
delete(p.progressInfoMap, name)
|
||||
p.s.FilesFinished++
|
||||
p.incrementFilesFinished(attrs)
|
||||
|
||||
p.printer.CompleteItem(action, name, bytesTotal)
|
||||
}
|
||||
|
|
15
internal/ui/restore/progress_unix.go
Normal file
15
internal/ui/restore/progress_unix.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package restore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
)
|
||||
|
||||
// incrementFilesFinished increments the files finished count
|
||||
func (p *Progress) incrementFilesFinished(_ map[restic.GenericAttributeType]json.RawMessage) {
|
||||
p.s.FilesFinished++
|
||||
}
|
14
internal/ui/restore/progress_windows.go
Normal file
14
internal/ui/restore/progress_windows.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package restore
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
)
|
||||
|
||||
// incrementFilesFinished increments the files finished count if it is a main file
|
||||
func (p *Progress) incrementFilesFinished(attrs map[restic.GenericAttributeType]json.RawMessage) {
|
||||
if string(attrs[restic.TypeIsADS]) != "true" {
|
||||
p.s.FilesFinished++
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue