przemoc / metastore

Store and restore metadata from a filesystem.
http://software.przemoc.net/#metastore
GNU General Public License v2.0
169 stars 31 forks source link

Add action to dump metadata in human-readable form (`-d`, `--dump`) #28

Closed przemoc closed 8 years ago

przemoc commented 8 years ago

Output should be similar to:

$ ls -alp --time-style=full-iso
total 4
drwxr-xr-x 1 przemoc przemoc   26 2015-09-06 19:45:34.222175902 +0200 ./
drwxr-xr-x 1 przemoc przemoc 2648 2015-09-07 16:02:10.047591753 +0200 ../
-rw-r--r-- 1 przemoc przemoc   99 2015-09-06 19:45:34.222175902 +0200 .metadata
-rw-r--r-- 1 przemoc przemoc    0 2015-09-06 19:27:41.334181566 +0200 test

Current idea is to output following tab-separated columns:

If file have extended attributes, then each attribute name and its value will be shown on new line in 6th column (xattr) with only 5th column (path) not cleared. Value will be shown as text in quotes if all bytes are within 32-126 range or as hex prefixed with 0x otherwise. Example:

$ metastore -d 
-rw-r--r--  przemoc przemoc 2015-09-06 19:27:41.334181566 +0200 ./test
                ./test  user.txt="tekst"
                ./test  user.bin=0x020100ff00

Path order will be undefined. But you'll be able pipe output to LC_ALL=C sort -t $'\t' -k5 (if you don't have bash/zsh, then replace $'\t' with literal tab in quotes).

By default dump should use existing metastore file (typically .metadata), as it was shown in above example, but it should be also able to dump metastore file that would be created if save action was used with given path. Example:

$ metastore -d .
-rw-r--r--  przemoc przemoc 2015-09-06 19:45:34.222175902 +0200 ./.metadata
drwxr-xr-x  przemoc przemoc 2015-09-06 19:45:34.222175902 +0200 ./
-rw-r--r--  przemoc przemoc 2015-09-06 19:27:41.334181566 +0200 ./test
                ./test  user.txt="tekst"
                ./test  user.bin=0x0201000000

Dump action is meant only as a helpful debugging facility/merge conflict helper. Do not ever compare dumps taken using different metastore version. Do not rely on current output format (especially in batch scripts), because it may change in future without prior notice.