mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
0e9716a6e6
Forget fs.Node instances once the kernel frees the corresponding nodeId. This ensures that restic does not run out of memory on large snapshots.
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
//go:build darwin || freebsd || linux
|
|
// +build darwin freebsd linux
|
|
|
|
package fuse
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/anacrolix/fuse"
|
|
"github.com/anacrolix/fuse/fs"
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
// Statically ensure that *other implements the given interface
|
|
var _ = fs.NodeForgetter(&other{})
|
|
var _ = fs.NodeReadlinker(&other{})
|
|
|
|
type other struct {
|
|
root *Root
|
|
forget forgetFn
|
|
node *restic.Node
|
|
inode uint64
|
|
}
|
|
|
|
func newOther(root *Root, forget forgetFn, inode uint64, node *restic.Node) (*other, error) {
|
|
return &other{root: root, forget: forget, inode: inode, node: node}, nil
|
|
}
|
|
|
|
func (l *other) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) {
|
|
return l.node.LinkTarget, nil
|
|
}
|
|
|
|
func (l *other) Attr(_ context.Context, a *fuse.Attr) error {
|
|
a.Inode = l.inode
|
|
a.Mode = l.node.Mode
|
|
|
|
if !l.root.cfg.OwnerIsRoot {
|
|
a.Uid = l.node.UID
|
|
a.Gid = l.node.GID
|
|
}
|
|
a.Atime = l.node.AccessTime
|
|
a.Ctime = l.node.ChangeTime
|
|
a.Mtime = l.node.ModTime
|
|
|
|
a.Nlink = uint32(l.node.Links)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (l *other) Forget() {
|
|
l.forget()
|
|
}
|