1
0
Fork 0
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:
aneesh-n 2024-12-03 18:00:14 +05:30
parent 400b0a3958
commit 27e165f43f
No known key found for this signature in database
GPG key ID: 6F5A52831C046F44
3 changed files with 41 additions and 2 deletions

View file

@ -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)
}

View 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++
}

View 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++
}
}