git-annex/doc/todo/adb_import.mdwn

38 lines
1.8 KiB
Text
Raw Normal View History

2019-04-09 18:07:47 +00:00
Make adb special remote support import tree.
This would be very useful for syncing with an android device without
needing to run git-annex on it. While git-annex works well enough in
termux, the horribleness of android's /sdcard makes it unappealing to put a
git annex repository on it (direct mode is still the best option there;
v7 unlocked works but without hard links has to store two copies of each
file).
This needs at a minimum a way to list files in a directory via adb,
in order to find new files. `adb shell find /sdcard/ -type f` seems to work
across a range of android versions (5.1, 8.1).
To avoid re-downloading each file each import, a way to list files
along with a good content identifier is needed.
`adb shell find /sdcard/ -type f -exec stat -c "'%d %i %s %Y %n'" {} +`
works on (5.1, 8.1) (note the weird quoting that it needs)
To avoid losing modifications to files
that the user makes using the android device while the same files are being
exported to it would need an upload to a temp location followed by a check
that the original is unmodified before renaming. This needs
shell scripting in android's limited shell environment, or
`adb shell stat 'origfile'` followed by `adb shell mv 'tmpfile' 'origfile'`.
That is necessarily racy, although the race window is
probably not much wider than the similar races when git checkout stats
work tree files before overwriting them.
Alternatively, the documentation could tell the user to avoid modifying files
on their android device while git-annex is exporting to it, or to instead
only ever modify files on the android device, and import from it, but not
export any changes to it. (Or some combination of those
for different subdirectories on it.) But it seems like this won't be
necessary.
> [[done]] --[[Joey]]