git-annex/doc/todo/adb_import.mdwn
Joey Hess 7b6d0da9b8
adb import
As well as adding the necessary methods, a few other changes to the adb
remote:

* Use ".annextmp" extension for temp files, to avoid conflict with other
  temp files.
* Stop using "echo $?" to get exit status of command inside adb.
  There were two problems; first the "echo" just before it meant it was
  always 0! And secondly, it seems kind of random on my phone whether it's
  1 or 0, not dependant on whether the command seems to have succeeded.
2019-04-09 17:52:41 -04:00

37 lines
1.8 KiB
Markdown

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]]