Skip to content

Commit fa0e1b3

Browse files
committed
Issue #35: Scripts for destructive filesystem operations.
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.
1 parent fa9c3f6 commit fa0e1b3

File tree

10 files changed

+70
-9
lines changed

10 files changed

+70
-9
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin
2+
/tmsu-*

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dist: compile
3535
cp README.md $(DIST_DIR)
3636
cp COPYING.md $(DIST_DIR)
3737
@mkdir -p $(DIST_DIR)/bin
38-
cp misc/bin/mount.tmsu $(DIST_DIR)/bin/
38+
cp misc/bin/* $(DIST_DIR)/bin/
3939
@mkdir -p $(DIST_DIR)/man
4040
gzip -fc misc/man/tmsu.1 >$(DIST_DIR)/man/tmsu.1.gz
4141
@mkdir -p $(DIST_DIR)/misc/zsh
@@ -47,6 +47,8 @@ install:
4747
cp bin/tmsu $(INSTALL_DIR)
4848
@echo "* Installing 'mount' command support"
4949
cp misc/bin/mount.tmsu $(MOUNT_INSTALL_DIR)
50+
@echo "* Installing scripts"
51+
cp misc/bin/tmsu-* $(INSTALL_DIR)
5052
@echo "* Installing man page"
5153
mkdir -p $(MAN_INSTALL_DIR)
5254
gzip -fc misc/man/tmsu.1 >$(MAN_INSTALL_DIR)/tmsu.1.gz

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ v0.6 (in development)
103103
only a single file argument, which is useful when using xargs.
104104
* Replaced 'stats' command with 'info' command (with --stats and --usage
105105
options for tag statics and usage counts respectively).
106+
* Included a set of scripts for performing filesystem operations whilst
107+
keeping the TMSU database up to date. If you wish to use these scripts
108+
I recommend you alias them to simpler names, e.g. 'trm'.
109+
- tmsu-rm! Removes files from the filesystem and TMSU
110+
- tmsu-mv! Moves a file in the filesystem and updates TMSU
111+
- tmsu-merge! Merges files (deleting all but the last)
106112

107113
v0.5.2
108114
------

misc/README

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
bin Supporting binaries.
2-
db-upgrade Database upgrade scripts.
3-
ebnf Extended Backus-Naur Form file for the TMSU query language.
4-
man Man page.
5-
zsh Command completion for the shell Zsh.
1+
bin Supporting executables
2+
mount.tmsu Support for 'mount' command
3+
tmsu-unsafe-rm Delete a file on the filesystem and remove it from TMSU
4+
tmsu-unsafe-mv Move a file and update the path in TMSU
5+
tmsu-unsafe-mf Merges two files by deleting the first and applying its tags to the second
6+
db-upgrade Database upgrade scripts
7+
ebnf Extended Backus-Naur Form file for the TMSU query language
8+
man Man page
9+
zsh Command completion for the shell Zsh

misc/bin/README

-1
This file was deleted.

misc/bin/tmsu-fs-merge

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
usage="\
4+
Merges two or more files
5+
6+
Each FILE's tags are applied to DESTFILE before being deleted from the filesystem.
7+
8+
Usage: $0 FILE... DESTFILE"
9+
10+
if test $# -lt 2; then
11+
echo "${usage}" 1>&2
12+
exit 1
13+
fi
14+
15+
eval last=\${$#}
16+
while test $# -gt 1; do
17+
tmsu tag --from $1 $last && tmsu-fs-rm $1
18+
shift
19+
done

misc/bin/tmsu-fs-mv

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
usage="\
4+
Moves a file in the filesystem and updates the path in TMSU
5+
6+
Usage: $0 SRCFILE DESTFILE"
7+
8+
if test $# -ne 2; then
9+
echo "${usage}" 1>&2
10+
exit 1
11+
fi
12+
13+
mv $1 $2 && tmsu repair --manual $1 $2

misc/bin/tmsu-fs-rm

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
usage="\
4+
Delete a file in the filesystem and TMSU
5+
6+
Usage: $0 FILE..."
7+
8+
if test $# -lt 1; then
9+
echo "${usage}" 1>&2
10+
exit 1
11+
fi
12+
13+
while test $# -gt 0; do
14+
tmsu untag --all $1 && rm $1
15+
shift
16+
done

misc/zsh/_tmsu

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ _tmsu_files() {
157157

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

163163
_describe -t files 'files' file_list

src/tmsu/cli/tag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func tagFrom(store *storage.Storage, tx *storage.Tx, fromPath string, paths []st
253253
return fmt.Errorf("%v: could not retrieve file: %v", fromPath, err)
254254
}
255255
if file == nil {
256-
return fmt.Errorf("%v: path is not tagged")
256+
return fmt.Errorf("%v: path is not tagged", fromPath)
257257
}
258258

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

0 commit comments

Comments
 (0)