LoginSignup
11
11

More than 5 years have passed since last update.

[Semantic File System]ファイルをタグで管理

Last updated at Posted at 2015-01-03

やりたいこと

  1. ファイルをタグで管理

  2. ファイルシステムとしてマウント可能
    →タグ名によって階層付けられたディレクトリ構成の自動構築、タグ名によるファイルの検索を行った場合、結果ファイルリストが1つのディレクトリに配置されるようにディレクトリ構成を再構築する。
    TagBasedhierarchicalDirectory

想定している利用例

音楽or動画ファイルを保存しているメディアサーバに、外部再生機器(PS4等)がアクセスしファイルを探す際にタグベースのファイルシステムを参照したい。

タグで整理されたディレクトリを作成

タグによる検索結果集合のディレクトリ作成

再生機器から、少ないディレクトリ移動でファイルにアクセス可能

補足:ファイルシステムが嬉しい理由

タグ情報があっても、タグによる検索を行う機能がなければ意味が無い。
ディレクトリ構成としてタグ検索結果を受け取れるなら、(手間は増えるが)外部機器に追加機能が不要となる。
TBFSUsecase

Semantic File Systemの実装例

タグベースのファイルシステムはSemantic File Systemと呼ぶようだ。
Tagsistant、dantalianが実装例として有名?

実装例一覧はこの辺りを参照のこと。
http://en.wikipedia.org/wiki/Semantic_file_system
https://inconsolation.wordpress.com/2014/12/10/tagfs-xtagfs-dhtfs-and-more-tag-youre-it/

TMSU

ドキュメントがわりかし分かりやすかったので、実装例の中からTMSUを選んだ。
http://tmsu.org/
https://github.com/oniony/TMSU

以下に導入、使用方法をまとめる(2015/01/03)。

導入

配布されているバイナリファイルだとglibc2.14を要求されるため、手動でコンパイル(CentOS6)。
導入手順は以下の流れ。

1. fuse, sqlite3のインストール
2. golangのインストール
3. GOPATHの設定
4. go-sqlite3とgo-fuseのインストール
5. TMSUのgit repositoryをクローン
6. TMSUのMake

詳細はREADME.mdとCOMPILING.mdに記載の通りだが、fuse利用の際、パーミッションの設定が必要。
http://l-w-i.net/t/fedora/sshfs_001.txt

# chmod o+rw /dev/fuse
これを実行しないとsshfs実行時に「fuse: failed to open /dev/fuse: Permission denied」というエラーになる。

# chmod 4755 /bin/fusermount
これを実行しないとsshfs実行時に「fuse: failed to exec fusermount: Permission denied」というエラーになる。

使用法

http://tmsu.org/
Quick tourより必要最低限の使用法のみ挙げる。
その他タグ一覧の出力や、タグの一括リネーム、複数ファイルに一括タグ追加等の機能もある。


タグ追加

$ tmsu tag summer.mp3 music big-jazz mp3
tmsu: New tag 'music'
tmsu: New tag 'big-jazz'
tmsu: New tag 'mp3'
$ tmsu tag spring.mp3 music mp3 folk
tmsu: New tag 'folk'

 


ディレクトリのマウント

$ mkdir mp
$ tmsu mount mp

 


タグ検索


mkdirでタグ検索と検索結果ディレクトリの作成を行う。
summer.1.mp3のように、ファイル名が変わっているが気にしない(TMSUで管理しているファイルID情報が付記されている)。
$ ls mp/queries
README.md
$ mkdir "mp/queries/mp3 and not folk"
$ ls "mp/queries/mp3 and not folk"
summer.1.mp3

 


問題点

タグ付きのファイルが移動しても、TMSUは自動で追わない。
https://github.com/oniony/TMSU/issues/11

mv $1 $2 && tmsu repair --manual $1 $2

Since tmsu doesn't explicitly monitor filesystem changes, it'd be nice if
there were an analogue of git mv - a move command that also adds the move
to the staging area - for tmsu, that would move the file while updating the
database so that no tag info is lost.

つぶやき

タグベースのファイル管理が流行するには

タグ情報は構造化しない方がスマートな気がする。

ファイルシステムを自作するなら

DBに直接バイナリデータとタグ情報を保存したい。

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11