If I have some number of source directories, e.g.
dir5, how can I create an automatically syncing "merged" destination directory that has all the files and directories of the source directories but doesn't involve duplicating files?
For example, I have the following source directory structure...
dir1/ - a - b dir2/ - b <-- Note the duplicate name, this one is more recent than dir1\b - c - dir2.1/ <-- Subdirectories present too. - z dir3/ - d
... which when "merged" would look like this:
merge/ - dir2.1/ - z - a - b <-- Which one to show is based on modified time; most recent first. - c - d
(Assume there could be dozens of directories with thousands of files and subdirectories.)
All the files and directories in the source list should remain in place and unchanged and the "merged" destination directory should take up no addition storage; i.e. It's possibly just all symlinks managed by some daemon using inotify. The source directories are also having files and subdirectories added and removed frequently and this needs to be reflected, as soon as possible, in the "merged" directory too.
Some usage examples:
I create a new file,
dir3/e, and it automatically and immediately (or within a few seconds) appears in the
I remove the file
dir1/a and it automatically and immediately (or within a few seconds) disappears from the
dir3/d by opening
dir1/b so it it has a newer modified date than
dir2/b and so
merge/b automatically updates to point to
dir1/b as it is the most recent.
dir1/b and now
merge/b will point to the older file
I attempt to create a file in
merge but get an error because doing so makes no sense!