This is a method for hiding broken links using git-annex views.
Each annex will need it's own name for this system to work. For this example I'll use "localdrive." After getting file content, run:
git-annex metadata --not --in=here --metadata in=localdrive . -s in-=localdrive
git-annex metadata --in=here --not --metadata in=localdrive . -s in+=localdrive
git-annex view /=*
git-annex vfilter in=localdrive
Unused links will be hidden. Folder structures will remain the same.
To switch back use:
git-annex vpop 2
Because this is a lot to type, I've placed these in a bash script in the base folder (ignored with .gitignore so it isn't sent to other repos). The local repo name can be changed by editing THISREPO:
#!/bin/bash
THISREPO='localdrive'
git-annex metadata --not --in=here --metadata in=$THISREPO . -s in-=$THISREPO
git-annex metadata --in=here --not --metadata in=$THISREPO . -s in+=$THISREPO
git-annex view /=*
git-annex vfilter in=$THISREPO
exit 0
Hiding Broken Links in Preferred Content Repos
If you have a repo with preferred content settings, this can be shortened to a single script which can be run to "refresh" the view:
#!/bin/bash
THISREPO='pcrepo'
git-annex vpop 2
git-annex sync
git-annex get --auto
git-annex metadata --not --in=here --metadata in=$THISREPO . -s in-=$THISREPO
git-annex metadata --in=here --not --metadata in=$THISREPO . -s in+=$THISREPO
git-annex view /=*
git-annex vfilter in=$THISREPO
exit 0
This works, but it's very inneficient. You're adding metadata (which is committed to git!) to represent location information. git-annex already knows about location information, so it could just look at it and use it to build the view.
The reason I haven't implemented this yet is I'm not clear about what to do if a file is dropped while in a view. It seems like git-annex should update the view to no longer show the dropped file. But this means that any change to a file's presence needs to update the view, and so it entangles the implementation of views with a core part of git-annex. And it might be pretty inneficient to need to build a new view branch each time a file is dropped too.
With your hack, the view doesn't automatically update when a file is dropped. Since you're using it this way, maybe you have some advice or thoughts about this question?
I thought about the same thing today.
Well view aren't changing automatically when you change metadata, you'd have to re-create the view by leaving and entering.
It would be great to have some "internal metadata" like if the file is present.
Good news everyone!
git annex adjust --hide-missing
sets up a branch where only files with content available are included. And once in such a branch,git annex sync
updates it as necessary to reflect changes in content availability.