opencloud
opencloud copied to clipboard
metadata backends inconsistently use .meta.lock vs .mpk vs .mlock
The messagepack_backend.go has:
// IsMetaFile returns whether the given path represents a meta file
func (MessagePackBackend) IsMetaFile(path string) bool {
return strings.HasSuffix(path, ".mpk") || strings.HasSuffix(path, ".mlock")
}
// ...
// MetadataPath returns the path of the file holding the metadata for the given path
func (MessagePackBackend) MetadataPath(n MetadataNode) string { return n.InternalPath() + ".mpk" }
// LockfilePath returns the path of the lock file
func (MessagePackBackend) LockfilePath(n MetadataNode) string { return n.InternalPath() + ".mlock" }
The xattrs_backend.go has
// IsMetaFile returns whether the given path represents a meta file
func (XattrsBackend) IsMetaFile(path string) bool { return strings.HasSuffix(path, ".meta.lock") }
// ...
// MetadataPath returns the path of the file holding the metadata for the given path
func (XattrsBackend) MetadataPath(n MetadataNode) string { return n.InternalPath() }
// LockfilePath returns the path of the lock file
func (XattrsBackend) LockfilePath(n MetadataNode) string { return n.InternalPath() + ".mlock" }
The hybrid_backend.go has
// IsMetaFile returns whether the given path represents a meta file
func (HybridBackend) IsMetaFile(path string) bool { return strings.HasSuffix(path, ".meta.lock") }
// ...
// MetadataPath returns the path of the file holding the metadata for the given path
func (b HybridBackend) MetadataPath(n MetadataNode) string {
base := b.metadataPathFunc(n)
return filepath.Join(base, pathify(n.GetID(), 4, 2)+".mpk")
}
// LockfilePath returns the path of the lock file
func (b HybridBackend) LockfilePath(n MetadataNode) string {
base := b.metadataPathFunc(n)
return filepath.Join(base, "locks", n.GetID()+".mlock")
}
IsMetaFile() is used by
- ListRevisions in pkg/storage/fs/posix/tree/revisions.go:
versionGlob := tp.lookup.VersionPath(n.SpaceID, n.ID, "*") if items, err := filepath.Glob(versionGlob); err == nil { for i := range items { if tp.lookup.MetadataBackend().IsMetaFile(items[i]) || strings.HasSuffix(items[i], ".mlock") { continue } - ListRevisions in pkg/storage/pkg/decomposedfs/tree/revisions.go:
np := n.InternalPath() if items, err := filepath.Glob(np + node.RevisionIDDelimiter + "*"); err == nil { for i := range items { if tp.lookup.MetadataBackend().IsMetaFile(items[i]) || strings.HasSuffix(items[i], ".mlock") { continue }
And finally, these are the only occurences of .meta.lock:
❯ grep -R ".meta.lock"
grep: cmd/revad/revad: Übereinstimmungen in Binärdatei
pkg/storage/pkg/decomposedfs/metadata/xattrs_backend.go:func (XattrsBackend) IsMetaFile(path string) bool { return strings.HasSuffix(path, ".meta.lock") }
pkg/storage/pkg/decomposedfs/metadata/hybrid_backend.go:func (HybridBackend) IsMetaFile(path string) bool { return strings.HasSuffix(path, ".meta.lock") }
pkg/storage/utils/decomposedfs/metadata/xattrs_backend.go:func (XattrsBackend) IsMetaFile(path string) bool { return strings.HasSuffix(path, ".meta.lock") }
AFAICT I was involved in this in https://github.com/cs3org/reva/pull/4033/files ...
Today, I think we should fix the implementation of the IsMetaFile functions and get rid of the manual HasSuffix(items[i], ".mlock" checks.