From eb0e8d316d8facedfd4e63c2845a3cfda9539863 Mon Sep 17 00:00:00 2001 From: Srigovind Nayak <5201843+konidev20@users.noreply.github.com> Date: Sat, 8 Feb 2025 16:06:03 +0530 Subject: [PATCH] mount: append repository ID to FS name of FUSE mount --- cmd/restic/cmd_mount.go | 10 +++++++++- internal/repository/repository.go | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index b8a66dc90..8ab951317 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -5,6 +5,7 @@ package main import ( "context" + "fmt" "os" "strings" "time" @@ -141,9 +142,16 @@ func runMount(ctx context.Context, opts MountOptions, gopts GlobalOptions, args return err } + repositoryID, err := repo.ID() + if err != nil { + return err + } + + fuseMountName := fmt.Sprintf("restic:%s", repositoryID) + mountOptions := []systemFuse.MountOption{ systemFuse.ReadOnly(), - systemFuse.FSName("restic"), + systemFuse.FSName(fuseMountName), systemFuse.MaxReadahead(128 * 1024), } diff --git a/internal/repository/repository.go b/internal/repository/repository.go index aee0db103..eda3d45ab 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -143,6 +143,15 @@ func (r *Repository) Config() restic.Config { return r.cfg } +// ID returns the repository ID. +func (r *Repository) ID() (restic.ID, error) { + id, err := restic.ParseID(r.cfg.ID) + if err != nil { + return restic.ID{}, err + } + return id, nil +} + // packSize return the target size of a pack file when uploading func (r *Repository) packSize() uint { return r.opts.PackSize