Commits

Paul Ruane committed 9349091

Fixed bug with unmount --all returning an error if there are no mounts.
Updated TODO.
Updated Zsh completion.

  • Participants
  • Parent commits 90b7fa7

Comments (0)

Files changed (5)

 0.0.8
 
 * 'unmount --all'
-* Allow tagged directory entries to be tagged and inherit parent tags.
+* Allow files within a tagged directory to be tagged (tag inheritence).
 * Allow actions to be performed on VFS files.
 * Improve unit-test coverage, especially database.
 
 * Handle case of attempting to mount VFS when already mounted at mp.
 * Getopt replacement.
 * Auto-tags (in general).
-* Improve Zsh completion so that only applicable tags are shown.
+* Zsh: show only applicable tags.
+* Zsh: show only mounted dirs on 'unmount' completion.
 * Exif

File misc/zsh/_tmsu

 
 _tmsu_cmd_mount() {
 	_arguments -s -w '1:file:_files' \
-	                 '2:mountpoint:_files' \
+	                 '2:mountpoint:_dirs' \
 	&& ret=0
 }
 
 }
 
 _tmsu_cmd_unmount() {
-	_arguments -s -w '1:mountpoint:_files' && ret=0
+	_arguments -s -w '--all' \
+	                 '1:mountpoint:_files' \
+	&& ret=0
 }
 
 _tmsu_cmd_untag() {

File src/tmsu/commands/mount.go

 
 	switch argCount {
 	case 0:
-		command.listMounts()
+        err := command.listMounts()
+        if err != nil {
+            return errors.New("Could not list mounts: " + err.Error())
+        }
 	case 1:
 		mountPath := args[0]
 

File src/tmsu/commands/unmount.go

 	"errors"
 	"os"
 	"os/exec"
+	"tmsu/vfs"
 )
 
 type UnmountCommand struct{}
 }
 
 func (UnmountCommand) Description() string {
-	return `tags unmount MOUNTPOINT
+	return `tmsu unmount MOUNTPOINT
+tmsu unmount --all
 
-Unmounts the virtual file-system at MOUNTPOINT.`
+Unmounts the virtual file-system at MOUNTPOINT.
+
+    --all    Unmounts all mounted TMSU file-systems.`
 }
 
-func (UnmountCommand) Exec(args []string) error {
+func (command UnmountCommand) Exec(args []string) error {
 	if len(args) < 1 {
 		return errors.New("Path to unmount not speciified.")
 	}
 
-	path := args[0]
+    if (args[0] == "--all") {
+        return command.unmountAll()
+    }
 
+    return command.unmount(args[0])
+}
+
+func (UnmountCommand) unmount(path string) error {
 	fusermountPath, err := exec.LookPath("fusermount")
 	if err != nil {
 		return err
 
 	return nil
 }
+
+func (command UnmountCommand) unmountAll() error {
+    mt, err := vfs.GetMountTable()
+    if err != nil {
+        return errors.New("Could not get mount table: " + err.Error())
+    }
+
+    for _, mount := range mt {
+        err = command.unmount(mount.MountPath)
+        if err != nil {
+            return err
+        }
+    }
+
+    return nil
+}

File src/tmsu/vfs/mtable.go

 }
 
 func GetMountTable() ([]Mount, error) {
-    //TODO change this to system calls
+    //TODO change this to examine /proc directly
 
     outputBytes, err := exec.Command("pgrep", "-f", "tmsu vfs").Output()
     if err != nil {
-        return nil, err
+        return []Mount{}, nil //TODO currently assumes no matches
     }
 
     pids := strings.Split(strings.Trim(string(outputBytes), "\n"), "\n")