data: split node and snapshot code from restic package

This commit is contained in:
Michael Eischer
2025-09-23 20:01:09 +02:00
parent c85b157e0e
commit 56ac8360c7
166 changed files with 1170 additions and 1107 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui/progress"
)
@@ -113,7 +114,7 @@ func (p *Progress) CompleteBlob(bytes uint64) {
// CompleteItem is the status callback function for the archiver when a
// file/dir has been saved successfully.
func (p *Progress) CompleteItem(item string, previous, current *restic.Node, s archiver.ItemStats, d time.Duration) {
func (p *Progress) CompleteItem(item string, previous, current *data.Node, s archiver.ItemStats, d time.Duration) {
if current == nil {
// error occurred, tell the status display to remove the line
p.mu.Lock()
@@ -123,7 +124,7 @@ func (p *Progress) CompleteItem(item string, previous, current *restic.Node, s a
}
switch current.Type {
case restic.NodeTypeDir:
case data.NodeTypeDir:
p.mu.Lock()
p.addProcessed(Counter{Dirs: 1})
p.mu.Unlock()
@@ -137,7 +138,7 @@ func (p *Progress) CompleteItem(item string, previous, current *restic.Node, s a
p.printer.CompleteItem("dir modified", item, s, d)
}
case restic.NodeTypeFile:
case data.NodeTypeFile:
p.mu.Lock()
p.addProcessed(Counter{Files: 1})
delete(p.currentFiles, item)

View File

@@ -6,6 +6,7 @@ import (
"time"
"github.com/restic/restic/internal/archiver"
"github.com/restic/restic/internal/data"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/ui/progress"
)
@@ -54,10 +55,10 @@ func TestProgress(t *testing.T) {
prog.CompleteBlob(1024)
// "dir unchanged"
node := restic.Node{Type: restic.NodeTypeDir}
node := data.Node{Type: data.NodeTypeDir}
prog.CompleteItem("foo", &node, &node, archiver.ItemStats{}, 0)
// "file new"
node.Type = restic.NodeTypeFile
node.Type = data.NodeTypeFile
prog.CompleteItem("foo", nil, &node, archiver.ItemStats{}, 0)
time.Sleep(10 * time.Millisecond)