option to skip directories

This commit is contained in:
Vincent Riquer 2013-03-09 01:44:41 +01:00
parent 982f2fe878
commit bc8d73d2d9
3 changed files with 17 additions and 1 deletions

13
atom
View File

@ -116,6 +116,9 @@ getConfigSource() {
'path') 'path')
sourcepath="$value" sourcepath="$value"
;; ;;
'skip')
skippeddirectories+=( "$value" )
;;
esac esac
} }
@ -542,6 +545,10 @@ createDestinations() {
getFiles() { getFiles() {
scantime=$(date +%s) scantime=$(date +%s)
for prune_expression in "${skippeddirectories[@]}"
do
prunes+="-path $sourcepath$prune_expression -prune -o "
done
# We probably have thousands of files, don't waste time on disk writes # We probably have thousands of files, don't waste time on disk writes
echo 'BEGIN TRANSACTION;' >&3 echo 'BEGIN TRANSACTION;' >&3
while read time size filename while read time size filename
@ -587,7 +594,7 @@ getFiles() {
*) ;; *) ;;
esac esac
done < <( done < <(
find "$sourcepath" -type f -printf "%T@ %s %P\n" find "$sourcepath" $prunes -type f -printf "%T@ %s %P\n"
) )
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3
echo -e "\r$count files found, ${new:=0} new or changed." echo -e "\r$count files found, ${new:=0} new or changed."
@ -955,6 +962,10 @@ General|Load|$maxload
|Debug|$debug |Debug|$debug
Source|Path|$sourcepath Source|Path|$sourcepath
EOF EOF
for prune_expression in "${skippeddirectories[@]}"
do
echo "|Skipped directory|$prune_expression"
done
for destination in ${!destinationpath[@]} for destination in ${!destinationpath[@]}
do do
cat <<EOF cat <<EOF

View File

@ -40,6 +40,8 @@ Sections:
* path <directory>: String. The root of your collection. * path <directory>: String. The root of your collection.
Default: /var/lib/mpd/music Default: /var/lib/mpd/music
* skip <directory>: String. Files in <directory> will be ignored. Note that
<directory> can be any expression accepted by find.
[<some arbitrary string>] [<some arbitrary string>]
Each section not named 'general' or 'source' will define a new destination. Each section not named 'general' or 'source' will define a new destination.

View File

@ -7,6 +7,9 @@ debug 0
[source] [source]
path /var/lib/mpd/music path /var/lib/mpd/music
skip /last
skip /lastfm
skip /zzz-atrier
[Ogg] [Ogg]
path /mnt/Musique-OggQ2 path /mnt/Musique-OggQ2