I'll do the ext3-boot switch over tonight, thanks for the tip, seems obvious now

As for diff, yeah, know about it, I was more unclear as to 'official' channels for submitting code for review but you guys seem to be all over these posts so code tags it is then... please note that not all code paths have been tested as I my setup only goes through the 'l3' section but the changes were straightforward enough to apply everywhere. My paths have tons of special characters in them (spaces, ampersands, etc.) so I don't think any escaping issues have been introduced... a fair number of comments have also been peppered into the code as the bash string manipulations are a bit more vague than a call to basename which is pretty obvious in what it's trying to do.
Oh, and a bit more detail about the speed, the 4x improvement was noted over the creation of about 4800 links (lots of which are for playlists, ie: all films with actor X in them). This took over 20 minutes with the original linksheets script, now is under 5 minutes... ymmv.
One additional speed improvement I debated over was to change the link creation from -fs to just -s (and ultimately skipping the fork to ln if the link already exists). This helps if there are a lot of collisions, which in my case there is because of the microscopic all-named-the-same playlists I'm using. In my case it would be fine because all collisions actually resolve to the same image anyway and the choice of taking first hit (like a change to -s would) .vs. taking the last hit (which is what -fs is doing) makes no difference, for other people it would mean that the wrong image is shown but the wrong ones would be different and previously wrong ones would now be correct... six of one, half dozen of the other.
And while I'm on a roll with the typing... I would kill to be able to avoid linksheets and not have to explore the existing alternatives either... can't there just be an option that always goes to the storage and reads the sheet or thumb file? This might introduce small browsing latency but at least be a mode where new sheets/thumbs show up right away so you can confirm everything is named properly and looks good. Effectively this is what is happening with 'folder.jpg' because that particular name is ubiquitous and can't be linked in... so can I select a behaviour like that for all sheet/thumbs and not just folder.jpg? Given that the actual image data has to be read off the device/network anyway I see little actual performance advantage in this indirect and imperfect mapping through /msheets... seriously, networks and disks are fast enough to just use directly for all cases, the limitations of linksheets and it's rebuild latency are far worse than the few 100ms it's going to take to get the exact right image every time.
Cheers
Chris
- Code: Select all
#!/usr/bin/bash
### Copyright 2010 b-rad.cc
### http://wdlxtv.com & http://b-rad.cc & http://nextdimension.cc
### GPLv3 - full license located @ /usr/share/LICENSE
### Stipulations:
### - the full copyright notices in /osd/setup_about.xml must be left intact, as it is the publicly displayed copyright portion of this software as dictated by the GPLv3
### - this entire header must be left intact
## linksheets <location> <mode>
## recursively searches and symlinks movie sheets into /msheets
## /msheets is joined with /osd via unionfs
## -- if <mode> == 2 then max-levels=2
##
## valid types
## video thumb view:
## audio thumb view:
## list mode:
## - STD
## - SHEET
## - WALL
##
[ -e /tmp/STOP_DMARENDER ] && exit 55
eval `egrep 'LISTNUM|GENTHUMBS|THUMBRESO|MSHEET|DEFAULTSHEET' /conf/config`
MODE=$2
if [ "$MSHEETMODE" == "wall" -o "$MSHEETMODE" == "sheet" -o "$MSHEETMODE" == "std" -a "$GENMSHEET" == "ON" -o "$VIDMSHEET" == "ON" -o "$LISTMSHEET" == "ON" -o "$MODE" == "5" ] ; then
SEARCHSTRING=".*_sheet.$MSHEETMODE.jpg"
else
exit 3
fi
[ ! -e "$1" ] && echo "PATH: $1 does not exist!" && exit 2
[ "$MODE" == "1" -o "$MODE" == "2" ] && DEPTH="-maxdepth $MODE" || DEPTH=""
logger -t linksheets "Generating MovieSheets for $1, mode $2"
echo "power led blink on" >> /proc/led
if [ "$DEFAULTSHEET" != "" -a ! -L /tmp/defaultsheet.jpg ]; then
if [ `echo "$DEFAULTSHEET" | grep -q '^/';echo $?` -eq 0 ]; then
ln -s "$DEFAULTSHEET" /tmp/defaultsheet.jpg
else
ln -s "/osd/$DEFAULTSHEET" /tmp/defaultsheet.jpg
fi
fi
cd /msheets
find "$1/" -type f -regextype posix-egrep -iregex ".*_sheet.jpg|.*wd_tv.jpg|$SEARCHSTRING" $DEPTH 2>/dev/null | while read msheet ; do
MSHEETBASE=${msheet##*/}
if [ "$MSHEETBASE" == "wd_tv.jpg" -o "$MSHEETBASE" == ".wd_tv.jpg" -a "$MSHEETMODE" != "std" ] ; then
if [ "$MSHEETBASE" == ".wd_tv.jpg" ] ; then
DIRNAME=${msheet/.wd_tv.jpg/}
else
DIRNAME=${msheet/wd_tv.jpg/}
fi
DIRNAME=${DIRNAME##*/} # extract the basename
if [ -h "$BASELINK" ] ; then # only spawn readlink if we have to
BASELINK="`/usr/bin/readlink "$DIRNAME"`"
else
BASELINK=$DIRNAME
fi
BASELINK=${BASELINK##*/} # extract the link's basepath
[ -n "$BASELINK" -a "$MSHEETMODE" == "std" -a "$BASELINK" == "$MSHEETBASE" ] && unlink "$DIRNAME" && [ -n "$LDEBUG" ] && echo "ul1 $MSHEETBASE -> $DIRNAME"
[ "$MSHEETMODE" != "std" ] && ln -fs "$msheet" "$DIRNAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l1 $MSHEETBASE -> $DIRNAME"
elif [ "$MSHEETBASE" == "folder.jpg_sheet.jpg" -o "$MSHEETBASE" == ".folder.jpg_sheet.jpg" -a "$MSHEETMODE" != "std" ] ; then
if [ "$MSHEETBASE" == ".folder.jpg_sheet.jpg" ] ; then
DIRNAME=${msheet/.folder.jpg_sheet.jpg/}
else
DIRNAME=${msheet/folder.jpg_sheet.jpg/}
fi
DIRNAME=${DIRNAME##*/} # extract the dir's basepath
NOEXT=${msheet/.jpg/}
if [ -h "$BASELINK" ] ; then # only spawn readlink if we have to
BASELINK="`/usr/bin/readlink "$DIRNAME"`"
else
BASELINK=$DIRNAME
fi
BASELINK=${BASELINK##*/} # extract the link's basepath
[ -n "$BASELINK" -a "$MSHEETMODE" == "std" -a "$BASELINK" == "$MSHEETBASE" ] && unlink "$DIRNAME" && [ -n "$LDEBUG" ] && echo "ul2 $MSHEETBASE -> $DIRNAME"
[ "$MSHEETMODE" != "std" -a ! -f "$NOEXT.$MSHEETMODE.jpg" ] && ln -fs "$msheet" "$DIRNAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l2 $MSHEETBASE -> $DIRNAME"
elif [ "${msheet/_sheet.jpg/}" != "$msheet" ] ; then
BASENAME=${msheet/_sheet.jpg/}
BASENAME=${BASENAME##*/} # extract basepath
BASENAME=${BASENAME#.} # remove leading period (if it exists)
NOEXT=${msheet/.jpg/}
DIRPATH=${msheet%/*} # extract dirpath
DIRNAME=${DIRPATH##*/} # extract the dir's basepath
if [ -h "$BASELINK" ] ; then # only spawn readlink if we have to
BASELINK="`/usr/bin/readlink "$DIRNAME"`"
else
BASELINK=$DIRNAME
fi
BASELINK=${BASELINK##*/} # extract the link's basepath
[ -n "$BASELINK" -a "$MSHEETMODE" == "std" -a "${BASELINK/_sheet.jpg/}" != "$DIRNAME" ] && unlink $DIRNAME && [ -n "$LDEBUG" ] && echo "ul3 $MSHEETBASE -> $DIRNAME"
if [ ! -f "$NOEXT.$MSHEETMODE.jpg" -a ! -f "$DIRPATH/folder.jpg_sheet.jpg" -a ! -f "$DIRPATH/folder.jpg_sheet.$MSHEETMODE.jpg" ] ; then
[ "$MSHEETMODE" != "std" ] && ln -fs "$msheet" "$DIRNAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l3 $MSHEETBASE -> $DIRNAME"
fi
[ ! -f "$NOEXT.$MSHEETMODE.jpg" ] && ln -fs "$msheet" "$BASENAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l3a $BASENAME -> $MSHEETBASE"
else
BASENAME=${msheet/_sheet.$MSHEETMODE.jpg/}
BASENAME=${BASENAME##*/} # extract basepath
BASENAME=${BASENAME#.} # remove leading period (if it exists)
DIRPATH=${msheet%/*} # extract dirpath
DIRNAME=${DIRPATH##*/} # extract the dir's basepath
if [ -h "$BASELINK" ] ; then # only spawn readlin if we have to
BASELINK="`/usr/bin/readlink "$DIRNAME"`"
else
BASELINK=$DIRNAME
fi
BASELINK=${BASELINK##*/} # extract the link's basepath
[ -n "$BASELINK" -a "$MSHEETMODE" == "std" -a "${BASELINK/_sheet.$MSHEETMODE.jpg/}" != "$DIRNAME" ] && unlink "$DIRNAME" && [ -n "$LDEBUG" ] && echo "ul4 $MSHEETBASE -> $DIRNAME"
if [ "$MSHEETMODE" != "std" -a "$BASENAME" == "folder.jpg" -o "$MSHEETMODE" != "std" ] ; then
[ ! -f "$DIRPATH/folder.jpg_sheet.jpg" -a ! -f "$DIRPATH/folder.jpg_sheet.$MSHEETMODE.jpg" ] && ln -fs "$msheet" "$DIRNAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l4 $MSHEETBASE -> $DIRNAME"
fi
ln -fs "$msheet" "$BASENAME" 2>/dev/null && [ -n "$LDEBUG" ] && echo "l4a $MSHEETBASE -> $BASENAME"
fi
[ -f /tmp/linksheets.stop.$MODE -o -f /tmp/linksheets.stop ] && echo "power led blink off" >> /proc/led && echo "power led on" >> /proc/led && logger -t linksheets "linksheets.stop found, exiting immediately!!!" && exit 3
# usleep 750
done
echo "power led blink off" >> /proc/led
echo "power led on" >> /proc/led