2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-30 00:33:57 +00:00

Make inodeFromBackendId more explicit

This commit is contained in:
Matthieu Rakotojaona 2015-07-19 16:39:17 +02:00
parent a4d122e5ae
commit fe6f1c01f3
3 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,6 @@
package fuse
import (
"encoding/binary"
"os"
"bazil.org/fuse"
@ -52,7 +51,7 @@ func newDirFromSnapshot(repo *repository.Repository, snapshot SnapshotWithId) (*
return &dir{
repo: repo,
children: children,
inode: binary.BigEndian.Uint64(snapshot.ID),
inode: inodeFromBackendId(snapshot.ID),
}, nil
}

14
cmd/restic/fuse/fuse.go Normal file
View 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])
}

View File

@ -1,7 +1,6 @@
package fuse
import (
"encoding/binary"
"os"
"sync"
"time"
@ -80,7 +79,7 @@ func (sn *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
ret := make([]fuse.Dirent, 0)
for _, snapshot := range sn.knownSnapshots {
ret = append(ret, fuse.Dirent{
Inode: binary.BigEndian.Uint64(snapshot.ID[:8]),
Inode: inodeFromBackendId(snapshot.ID),
Type: fuse.DT_Dir,
Name: snapshot.Time.Format(time.RFC3339),
})