mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
Add more error reporting
This commit is contained in:
parent
865d315ad6
commit
aca0692ee6
16
archiver.go
16
archiver.go
@ -185,6 +185,7 @@ func (arch *Archiver) SaveFile(p *Progress, node *Node) (Blobs, error) {
|
||||
// create new node
|
||||
n, err := NodeFromFileInfo(node.path, fi)
|
||||
if err != nil {
|
||||
debug.Log("Archiver.SaveFile", "NodeFromFileInfo returned error for %v: %v", node.path, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -405,7 +406,11 @@ func (arch *Archiver) fileWorker(wg *sync.WaitGroup, p *Progress, done <-chan st
|
||||
|
||||
node, err := NodeFromFileInfo(e.Fullpath(), e.Info())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
// TODO: integrate error reporting
|
||||
debug.Log("Archiver.fileWorker", "NodeFromFileInfo returned error for %v: %v", node.path, err)
|
||||
e.Result() <- nil
|
||||
p.Report(Stat{Files: 1})
|
||||
continue
|
||||
}
|
||||
|
||||
// try to use old node, if present
|
||||
@ -825,6 +830,15 @@ func Scan(dirs []string, p *Progress) (Stat, error) {
|
||||
debug.Log("Scan", "Start for %v", dir)
|
||||
err := filepath.Walk(dir, func(str string, fi os.FileInfo, err error) error {
|
||||
debug.Log("Scan.Walk", "%v, fi: %v, err: %v", str, fi, err)
|
||||
// TODO: integrate error reporting
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error for %v: %v\n", str, err)
|
||||
return nil
|
||||
}
|
||||
if fi == nil {
|
||||
fmt.Fprintf(os.Stderr, "error for %v: FileInfo is nil\n", str)
|
||||
return nil
|
||||
}
|
||||
s := Stat{}
|
||||
if isFile(fi) {
|
||||
s.Files++
|
||||
|
@ -11,10 +11,10 @@ import (
|
||||
"github.com/restic/restic/debug"
|
||||
)
|
||||
|
||||
func (node *Node) fill_extra(path string, fi os.FileInfo) (err error) {
|
||||
func (node *Node) fill_extra(path string, fi os.FileInfo) error {
|
||||
stat, ok := fi.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
node.ChangeTime = time.Unix(stat.Ctim.Unix())
|
||||
@ -23,7 +23,7 @@ func (node *Node) fill_extra(path string, fi os.FileInfo) (err error) {
|
||||
node.GID = stat.Gid
|
||||
|
||||
// TODO: cache uid lookup
|
||||
if u, nil := user.LookupId(strconv.Itoa(int(stat.Uid))); err == nil {
|
||||
if u, err := user.LookupId(strconv.Itoa(int(stat.Uid))); err == nil {
|
||||
node.User = u.Username
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@ func (node *Node) fill_extra(path string, fi os.FileInfo) (err error) {
|
||||
|
||||
node.Inode = stat.Ino
|
||||
|
||||
var err error
|
||||
|
||||
switch node.Type {
|
||||
case "file":
|
||||
node.Size = uint64(stat.Size)
|
||||
|
Loading…
Reference in New Issue
Block a user