Commits

Paul Ruane  committed d7d96a2

Query directory now contains a README file if no queries have been created.

  • Participants
  • Parent commits 2612834

Comments (0)

Files changed (1)

File src/tmsu/vfs/fusevfs.go

 
 const tagsDir = "tags"
 const queriesDir = "queries"
+const queryDirHelp = `Create a directory with the query text as the directory name:.
+
+  $ mkdir "cheese and wine"
+  $ mkdir "cheese and not wine"
+  $ mkdir "cheese and (biscuits or wine)"
+  $ mkdir "cheese and not (pineapple or biscuits or wine)"`
 
 type FuseVfs struct {
 	store     *storage.Storage
 	log.Infof(2, "BEGIN Open(%v)", name)
 	defer log.Infof(2, "END Open(%v)", name)
 
+	if name == filepath.Join(queriesDir, "README") {
+		return nodefs.NewDataFile([]byte(queryDirHelp)), fuse.OK
+	}
+
 	return nil, fuse.ENOSYS
 }
 
 		log.Fatalf("Could not retrieve queries: %v", err)
 	}
 
+	if len(queries) == 0 {
+		return []fuse.DirEntry{fuse.DirEntry{Name: "README", Mode: fuse.S_IFREG}}, fuse.OK
+	}
+
 	entries := make([]fuse.DirEntry, len(queries))
 	for index, query := range queries {
 		entries[index] = fuse.DirEntry{Name: query.Text, Mode: fuse.S_IFDIR}
 	pathLength := len(path)
 	name := path[pathLength-1]
 
+	if len(path) == 1 && path[0] == "README" {
+		now := time.Now()
+		return &fuse.Attr{Mode: fuse.S_IFREG | 0644, Nlink: 1, Size: uint64(len(queryDirHelp)), Mtime: uint64(now.Unix()), Mtimensec: uint32(now.Nanosecond())}, fuse.OK
+	}
+
 	fileId := vfs.parseFileId(name)
 	if fileId != 0 {
 		return vfs.getFileEntryAttr(fileId)