Skip to content

Commit

Permalink
Issue #148: VFS directories not shown for values
Browse files Browse the repository at this point in the history
Made fix on maintenance branch
  • Loading branch information
oniony committed Oct 5, 2018
1 parent 1bb1ece commit 797862b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/github.com/oniony/TMSU/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ import (
"github.com/oniony/TMSU/common"
)

var Version = common.ParseVersion("0.7.0")
var Version = common.ParseVersion("0.7.2")
27 changes: 24 additions & 3 deletions src/github.com/oniony/TMSU/vfs/fusevfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ func MountVfs(store *storage.Storage, mountPath string, options []string) (*Fuse
return nil, fmt.Errorf("could not mount virtual filesystem at '%v': %v", mountPath, err)
}

absMountPath, err := filepath.Abs(mountPath)
if err != nil {
return nil, fmt.Errorf("could not convert mount path '%v' to absolute: %v", mountPath, err)
}

fuseVfs.store = store
fuseVfs.mountPath = mountPath
fuseVfs.mountPath = absMountPath
fuseVfs.server = server

return &fuseVfs, nil
Expand Down Expand Up @@ -315,7 +320,7 @@ func (vfs FuseVfs) Readlink(name string, context *fuse.Context) (string, fuse.St
path := vfs.splitPath(name)
switch path[0] {
case tagsDir, queriesDir:
return vfs.readTaggedEntryLink(tx, path[1:])
return vfs.readTaggedEntryLink(tx, path)
}

return "", fuse.ENOENT
Expand Down Expand Up @@ -838,6 +843,12 @@ func (vfs FuseVfs) openTaggedEntryDir(tx *storage.Tx, path []string) ([]fuse.Dir

var valueNames []string
if lastPathElement[0] != '=' {
expression := pathToExpression(path[:len(path)-1])
files, err := vfs.store.FilesForQuery(tx, expression, "", false, false, "name")
if err != nil {
log.Fatalf("could not query files: %v", err)
}

tagName := unescape(lastPathElement)

valueNames, err = vfs.tagValueNamesForFiles(tx, tagName, files)
Expand Down Expand Up @@ -963,7 +974,13 @@ func (vfs FuseVfs) readTaggedEntryLink(tx *storage.Tx, path []string) (string, f
log.Fatalf("could not find file %v in database.", fileId)
}

return file.Path(), fuse.OK
absDirPath := filepath.Join(vfs.mountPath, filepath.Join(path[:len(path)-1]...))
relPath, err := filepath.Rel(absDirPath, file.Path())
if err != nil {
log.Fatalf("could not make relative path: %v", err)
}

return relPath, fuse.OK
}

func (vfs FuseVfs) getLinkName(file *entities.File) string {
Expand Down Expand Up @@ -1091,6 +1108,10 @@ func pathToExpression(path []string) query.Expression {

elementExpression = query.ComparisonExpression{query.TagExpression{tagName}, "==", query.ValueExpression{valueName}}
} else {
if index+1 >= len(path) || path[index+1][0] == '=' {
continue
}

tagName := unescape(element)
elementExpression = query.TagExpression{tagName}
}
Expand Down

0 comments on commit 797862b

Please sign in to comment.