mirror of https://github.com/restic/restic.git
fixed compilation issues
This commit is contained in:
parent
3541a3a1bf
commit
e977c9f798
|
@ -48,17 +48,19 @@ type fileNode struct {
|
||||||
|
|
||||||
func listNodes(ctx context.Context, repo restic.Repository, tree restic.ID, path string) ([]fileNode, error) {
|
func listNodes(ctx context.Context, repo restic.Repository, tree restic.ID, path string) ([]fileNode, error) {
|
||||||
var files []fileNode
|
var files []fileNode
|
||||||
err := walker.Walk(ctx, repo, tree, nil, func(_ restic.ID, nodepath string, node *restic.Node, err error) (bool, error) {
|
err := walker.Walk(ctx, repo, tree, walker.WalkVisitor{
|
||||||
if err != nil || node == nil {
|
ProcessNode: func(parentTreeID restic.ID, nodepath string, node *restic.Node, err error) error {
|
||||||
return false, err
|
if err != nil || node == nil {
|
||||||
}
|
return err
|
||||||
if fs.HasPathPrefix(path, nodepath) {
|
}
|
||||||
files = append(files, fileNode{nodepath, node})
|
if fs.HasPathPrefix(path, nodepath) {
|
||||||
}
|
files = append(files, fileNode{nodepath, node})
|
||||||
if node.Type == "dir" && !fs.HasPathPrefix(nodepath, path) {
|
}
|
||||||
return false, walker.ErrSkipNode
|
if node.Type == "dir" && !fs.HasPathPrefix(nodepath, path) {
|
||||||
}
|
return walker.ErrSkipNode
|
||||||
return false, nil
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
})
|
})
|
||||||
return files, err
|
return files, err
|
||||||
}
|
}
|
||||||
|
@ -68,21 +70,18 @@ func runWebServer(ctx context.Context, opts ServeOptions, gopts GlobalOptions, a
|
||||||
return errors.Fatal("this command does not accept additional arguments")
|
return errors.Fatal("this command does not accept additional arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
repo, err := OpenRepository(ctx, gopts)
|
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, gopts.NoLock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer unlock()
|
||||||
|
|
||||||
if !gopts.NoLock {
|
snapshotLister, err := restic.MemorizeList(ctx, repo, restic.SnapshotFile)
|
||||||
var lock *restic.Lock
|
if err != nil {
|
||||||
lock, ctx, err = lockRepo(ctx, repo)
|
return err
|
||||||
defer unlockRepo(lock)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
bar := newIndexProgress(gopts.Quiet, gopts.JSON)
|
||||||
err = repo.LoadIndex(ctx)
|
err = repo.LoadIndex(ctx, bar)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -98,7 +97,7 @@ func runWebServer(ctx context.Context, opts ServeOptions, gopts GlobalOptions, a
|
||||||
curPath = "/" + strings.Trim(curPath, "/")
|
curPath = "/" + strings.Trim(curPath, "/")
|
||||||
_ = r.ParseForm()
|
_ = r.ParseForm()
|
||||||
|
|
||||||
sn, err := restic.FindSnapshot(ctx, repo.Backend(), repo, snapshotID)
|
sn, _, err := restic.FindSnapshot(ctx, snapshotLister, repo, snapshotID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Snapshot not found: "+err.Error(), http.StatusNotFound)
|
http.Error(w, "Snapshot not found: "+err.Error(), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
@ -164,7 +163,7 @@ func runWebServer(ctx context.Context, opts ServeOptions, gopts GlobalOptions, a
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var rows []indexPageRow
|
var rows []indexPageRow
|
||||||
for sn := range FindFilteredSnapshots(ctx, repo.Backend(), repo, &restic.SnapshotFilter{}, nil) {
|
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &restic.SnapshotFilter{}, nil) {
|
||||||
rows = append(rows, indexPageRow{"/tree/" + sn.ID().Str() + "/", sn.ID().Str(), sn.Time, sn.Hostname, sn.Tags, sn.Paths})
|
rows = append(rows, indexPageRow{"/tree/" + sn.ID().Str() + "/", sn.ID().Str(), sn.Time, sn.Hostname, sn.Tags, sn.Paths})
|
||||||
}
|
}
|
||||||
sort.Slice(rows, func(i, j int) bool {
|
sort.Slice(rows, func(i, j int) bool {
|
||||||
|
@ -255,7 +254,7 @@ const treePageTpl = `<html>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|
||||||
const stylesheetTxt = `
|
const stylesheetTxt = `
|
||||||
h1,h2,h3 {text-align:center; margin: 0.5em;}
|
h1,h2,h3 {text-align:center; margin: 0.5em;}
|
||||||
table {margin: 0 auto;border-collapse: collapse; }
|
table {margin: 0 auto;border-collapse: collapse; }
|
||||||
|
|
Loading…
Reference in New Issue