master
go 31 lines 1.33 KB
Raw
1 // Package fusemount provides internal helpers shared between the FUSE
2 // mount layer and the core API. It lives under internal/ so that
3 // external consumers of kubo cannot bypass publish guards.
4 package fusemount
5
6 import "context"
7
8 // publishKey is a context key that lets the IPNS FUSE mount's
9 // internal MFS republisher bypass the "cannot manually publish while
10 // IPNS is mounted" guard in the Name API. Without this bypass the
11 // guard blocks the mount's own publishes and silently drops IPNS
12 // updates, causing data written through the FUSE mount to be lost
13 // on daemon restart (see https://github.com/ipfs/kubo/issues/2168).
14 //
15 // TODO: the /ipns/ FUSE mount does not detect changes when a
16 // locally-owned key is published via `ipfs name publish` (RPC/CLI).
17 // A larger refactor is needed so the mountpoint's MFS representation
18 // is updated to reflect external publishes to locally-owned keys,
19 // rather than silently overwriting them on the next MFS flush.
20 type publishKey struct{}
21
22 // ContextWithPublish marks ctx as originating from the FUSE mount's
23 // internal publish path.
24 func ContextWithPublish(ctx context.Context) context.Context {
25 return context.WithValue(ctx, publishKey{}, true)
26 }
27
28 // IsPublish reports whether ctx was marked by [ContextWithPublish].
29 func IsPublish(ctx context.Context) bool {
30 return ctx.Value(publishKey{}) != nil
31 }