Make inodeFromBackendId more explicit
This commit is contained in:
parent
a4d122e5ae
commit
fe6f1c01f3
3 changed files with 16 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
||||||
package fuse
|
package fuse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"bazil.org/fuse"
|
"bazil.org/fuse"
|
||||||
|
@ -52,7 +51,7 @@ func newDirFromSnapshot(repo *repository.Repository, snapshot SnapshotWithId) (*
|
||||||
return &dir{
|
return &dir{
|
||||||
repo: repo,
|
repo: repo,
|
||||||
children: children,
|
children: children,
|
||||||
inode: binary.BigEndian.Uint64(snapshot.ID),
|
inode: inodeFromBackendId(snapshot.ID),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
cmd/restic/fuse/fuse.go
Normal file
14
cmd/restic/fuse/fuse.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package fuse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
|
"github.com/restic/restic/backend"
|
||||||
|
)
|
||||||
|
|
||||||
|
// inodeFromBackendId returns a unique uint64 from a backend id.
|
||||||
|
// Endianness has no specific meaning, it is just the simplest way to
|
||||||
|
// transform a []byte to an uint64
|
||||||
|
func inodeFromBackendId(id backend.ID) uint64 {
|
||||||
|
return binary.BigEndian.Uint64(id[:8])
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package fuse
|
package fuse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -80,7 +79,7 @@ func (sn *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
ret := make([]fuse.Dirent, 0)
|
ret := make([]fuse.Dirent, 0)
|
||||||
for _, snapshot := range sn.knownSnapshots {
|
for _, snapshot := range sn.knownSnapshots {
|
||||||
ret = append(ret, fuse.Dirent{
|
ret = append(ret, fuse.Dirent{
|
||||||
Inode: binary.BigEndian.Uint64(snapshot.ID[:8]),
|
Inode: inodeFromBackendId(snapshot.ID),
|
||||||
Type: fuse.DT_Dir,
|
Type: fuse.DT_Dir,
|
||||||
Name: snapshot.Time.Format(time.RFC3339),
|
Name: snapshot.Time.Format(time.RFC3339),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue