From 5789ec4b8d3c8ceb2e7323ba3fd7aa3f21702813 Mon Sep 17 00:00:00 2001 From: mpl Date: Wed, 16 May 2018 17:58:07 +0200 Subject: [PATCH] pkg/fs: add sha224-xx...xx hint dir And fix sha1 assumption for file name. Fixes #1169 Change-Id: I2a907c6cf11631a4a86268a4dc393c64402b5d35 --- cmd/pk-mount/doc.go | 5 +++-- pkg/fs/fs_test.go | 2 +- pkg/fs/recent.go | 2 +- pkg/fs/root.go | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/pk-mount/doc.go b/cmd/pk-mount/doc.go index 493f17d52..d709fbc81 100644 --- a/cmd/pk-mount/doc.go +++ b/cmd/pk-mount/doc.go @@ -35,6 +35,7 @@ Execute the following commands in a shell to mount a Perkeep directory in your h recent roots sha1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + sha224-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tag @@ -70,10 +71,10 @@ The at directory contains full instructions in the README.txt file contained wit Accessing a specific Node -You can directly access a specific directory by using the full sha1 identifier. +You can directly access a specific directory by using the full sha224 identifier. cd ~/Perkeep - cd sha1-xxx # where xxx is the full 16 character identifier + cd sha224-xxx # where xxx is the full 56 character identifier Full Command Line Usage diff --git a/pkg/fs/fs_test.go b/pkg/fs/fs_test.go index 3a1b166e8..40f1755ed 100644 --- a/pkg/fs/fs_test.go +++ b/pkg/fs/fs_test.go @@ -217,7 +217,7 @@ func TestRoot(t *testing.T) { t.Fatal(err) } sort.Strings(names) - want := []string{"WELCOME.txt", "at", "date", "recent", "roots", "sha1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "tag", "versions"} + want := []string{"WELCOME.txt", "at", "date", "recent", "roots", "sha1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "sha224-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "tag", "versions"} if !reflect.DeepEqual(names, want) { t.Errorf("root directory = %q; want %q", names, want) } diff --git a/pkg/fs/recent.go b/pkg/fs/recent.go index fac77a295..001fb85f9 100644 --- a/pkg/fs/recent.go +++ b/pkg/fs/recent.go @@ -119,7 +119,7 @@ func (n *recentDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { if ext == "" && ccMeta.File != nil && strings.HasSuffix(ccMeta.File.MIMEType, "image/jpeg") { ext = ".jpg" } - name = strings.TrimPrefix(ccMeta.BlobRef.String(), "sha1-")[:10] + ext + name = strings.TrimPrefix(ccMeta.BlobRef.String(), ccMeta.BlobRef.HashName()+"-")[:10] + ext if n.ents[name] != nil { continue } diff --git a/pkg/fs/root.go b/pkg/fs/root.go index d3a03f7f2..8f1e1c32c 100644 --- a/pkg/fs/root.go +++ b/pkg/fs/root.go @@ -64,6 +64,7 @@ func (n *root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { {Name: "roots"}, {Name: "at"}, {Name: "sha1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}, + {Name: "sha224-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}, {Name: "versions"}, }, nil } @@ -123,6 +124,8 @@ func (n *root) Lookup(ctx context.Context, name string) (fs.Node, error) { return n.getVersionsDir(), nil case "sha1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": return notImplementDirNode{}, nil + case "sha224-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": + return notImplementDirNode{}, nil case ".camli_fs_stats": return statsDir{}, nil case "mach_kernel", ".hidden", "._.":