[Digikam-devel] [Bug 109820] Offer: Utility script to export tag information of images into the filesystem

Mats Ahlgren ahlgren at mit.edu
Wed Jul 26 18:39:55 BST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=109820         




------- Additional Comments From ahlgren mit edu  2006-07-26 19:39 -------
I discovered unfortunately that relative symlinks do not work correctly due to a strange interaction with the hierarchicalness of the data folders. The only way to get any usefulness out of symlinks is to use ".." or "~"; .. doesn't work because links deeper in the tree need extra ..s to get out of the tree, and ~ doesn't work because "ln -s" auto-expands the ~ symbol before the symlink is ever created.

Thus, there are two solutions I can see:

1) Augment the script to keep track of the depth of the tree while constructing the symlink's path, and prepend that number of "../"s before the symlink (give or take 1).

2) Taking inspiration from the UNIX filesystem, I designed a very cute indirection layer that works with your script. You create a symlink in /usr/local/, call it symlink-to-album1, and link it to your pictures. All symlinks in the tree structure are given the absolute path to /usr/local/symlink-to-album1, which is itself a symlink and resolved to the album. This is a very hackish and doesn't work well with multiple tag-trees, but allows people to share the tree of symlinks between computers while only having to run 2 bash commands and without having to recreate the absolute path.

3) Use hard links. If all you care about is tgz'ing your pictures to send to a friend, and don't mind there being duplicates, then that's one way to do it I think. Hard links also prevent symlinks from being messed up when you reorganize your digiKam album hierarchy, but a simple re-invocation of your script gets around that problem.

I've come up with the perfect solution which is a blend of #1 and 2, but despite your code being wonderfully commented and clean, I'm not comfortable enough with Perl to make the changes, so I detail my suggestions below:

-- Suggestions:

Allow the script to take an "--export" argument, signifying the user wishes to make a file bundle they can email to a friend running any UNIX-based OS.

Change the directory structure to be:
> $linktreeRootDir/
> > README.txt
> > compress-into-tar-gzip.sh ( only create if args contain "--export" )
> > hardlink-to-photos/ ( a hard link to $photoRootDir )
> > tag-tree/
> > > ( script puts all symlinks here )

README.txt : Your man page. I was in the process of writing up a doc to tell novice users what a symlink is, why they should leave everything inside the linktreeRootDir intact, why this only works with UNIX-based OSes like Linux and Mac, that changing their photo album hierarchy will mess up the links, and what anything else does (e.g. clean-links if you think it's worth including).

compress-into-targzip.sh : This script will run "cd ..; tar -cvvzf $linktreeRootDir_archive.tgz $linktreeRootDir"

hardlink-to-photos : This is an indirection layer. It seemed like the easiest way to do things; nomatter where you move your linktreeRootDirectory, the links will always remain in place.

tag-tree : All symlink paths from the directory "tag1/tag2/tag3/.../tagN/" should be prefixed by (N+1)x"../" + "symlink-to-photos/" + "tag1/tag2/tag3/.../tagN/symlink"

(I also had other ideas, like using a clean-links script to allow you to send only part of your album collection, but I thought this was the most efficient way.)

Possible bug:
Also, I didn't have a chance to go through your code fully, so I can't tell if this is a problem or not. It might be the case that your script doesn't correct handle two tags with the same name, such as /people/college/friends and /people/gradeschool/friends.



More information about the Digikam-devel mailing list