Skip to content

Commit

Permalink
Issue #35: Scripts for destructive filesystem operations.
Browse files Browse the repository at this point in the history
Added scripts for performing destructive filesystem operations.
Updated README.
Added .gitignore which was, for some reason, itself ignored.
Updated Zsh completion, as 'untag' file matching was broken by the move
to relative paths in the database.
  • Loading branch information
oniony committed Apr 15, 2015
1 parent fa9c3f6 commit fa0e1b3
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
/tmsu-*
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dist: compile
cp README.md $(DIST_DIR)
cp COPYING.md $(DIST_DIR)
@mkdir -p $(DIST_DIR)/bin
cp misc/bin/mount.tmsu $(DIST_DIR)/bin/
cp misc/bin/* $(DIST_DIR)/bin/
@mkdir -p $(DIST_DIR)/man
gzip -fc misc/man/tmsu.1 >$(DIST_DIR)/man/tmsu.1.gz
@mkdir -p $(DIST_DIR)/misc/zsh
Expand All @@ -47,6 +47,8 @@ install:
cp bin/tmsu $(INSTALL_DIR)
@echo "* Installing 'mount' command support"
cp misc/bin/mount.tmsu $(MOUNT_INSTALL_DIR)
@echo "* Installing scripts"
cp misc/bin/tmsu-* $(INSTALL_DIR)
@echo "* Installing man page"
mkdir -p $(MAN_INSTALL_DIR)
gzip -fc misc/man/tmsu.1 >$(MAN_INSTALL_DIR)/tmsu.1.gz
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ v0.6 (in development)
only a single file argument, which is useful when using xargs.
* Replaced 'stats' command with 'info' command (with --stats and --usage
options for tag statics and usage counts respectively).
* Included a set of scripts for performing filesystem operations whilst
keeping the TMSU database up to date. If you wish to use these scripts
I recommend you alias them to simpler names, e.g. 'trm'.
- tmsu-rm! Removes files from the filesystem and TMSU
- tmsu-mv! Moves a file in the filesystem and updates TMSU
- tmsu-merge! Merges files (deleting all but the last)

v0.5.2
------
Expand Down
14 changes: 9 additions & 5 deletions misc/README
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
bin Supporting binaries.
db-upgrade Database upgrade scripts.
ebnf Extended Backus-Naur Form file for the TMSU query language.
man Man page.
zsh Command completion for the shell Zsh.
bin Supporting executables
mount.tmsu Support for 'mount' command
tmsu-unsafe-rm Delete a file on the filesystem and remove it from TMSU
tmsu-unsafe-mv Move a file and update the path in TMSU
tmsu-unsafe-mf Merges two files by deleting the first and applying its tags to the second
db-upgrade Database upgrade scripts
ebnf Extended Backus-Naur Form file for the TMSU query language
man Man page
zsh Command completion for the shell Zsh
1 change: 0 additions & 1 deletion misc/bin/README

This file was deleted.

19 changes: 19 additions & 0 deletions misc/bin/tmsu-fs-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

usage="\
Merges two or more files
Each FILE's tags are applied to DESTFILE before being deleted from the filesystem.
Usage: $0 FILE... DESTFILE"

if test $# -lt 2; then
echo "${usage}" 1>&2
exit 1
fi

eval last=\${$#}
while test $# -gt 1; do
tmsu tag --from $1 $last && tmsu-fs-rm $1
shift
done
13 changes: 13 additions & 0 deletions misc/bin/tmsu-fs-mv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

usage="\
Moves a file in the filesystem and updates the path in TMSU
Usage: $0 SRCFILE DESTFILE"

if test $# -ne 2; then
echo "${usage}" 1>&2
exit 1
fi

mv $1 $2 && tmsu repair --manual $1 $2
16 changes: 16 additions & 0 deletions misc/bin/tmsu-fs-rm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

usage="\
Delete a file in the filesystem and TMSU
Usage: $0 FILE..."

if test $# -lt 1; then
echo "${usage}" 1>&2
exit 1
fi

while test $# -gt 0; do
tmsu untag --all $1 && rm $1
shift
done
2 changes: 1 addition & 1 deletion misc/zsh/_tmsu
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ _tmsu_files() {

_call_program tmsu tmsu $db files | while read -A file
do
file_list+=$file:s/\.\///
file_list+=$file
done

_describe -t files 'files' file_list
Expand Down
2 changes: 1 addition & 1 deletion src/tmsu/cli/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func tagFrom(store *storage.Storage, tx *storage.Tx, fromPath string, paths []st
return fmt.Errorf("%v: could not retrieve file: %v", fromPath, err)
}
if file == nil {
return fmt.Errorf("%v: path is not tagged")
return fmt.Errorf("%v: path is not tagged", fromPath)
}

fileTags, err := store.FileTagsByFileId(tx, file.Id, true)
Expand Down

0 comments on commit fa0e1b3

Please sign in to comment.