-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adb-sync doesn't copy files properly if names are same on local and remote #50
Comments
I'm trying this small change to DiffLists. The issue here is that comparing mod times between OSX files and Android device files doesn't line up. I'm having to munge the times to get the comparison to skip files already copied over previously. I tried snapping to minutes and then adding 16. So how can this sync ever work, if the timestamps don't have even a remote correspondence. I tried with --times and without.
Modification timestamps seems to be an underlying flaw in the Android file system. And some circular references back to that unresolved issue, but more of a description of the problem. It's clear from --times still being broken in the release buld that timestamp comparisons in adb-sync were never tested/used. |
Also seems like there's an "adb shell stat -c "%y" filename" command that might return more precise timings than "ls -al" which only shows timings to minutes. But this would have to get called for each filename. At least here the seconds are available. 2020-11-25 00:16:05.000000000 There's also "ls -ll" to get more accurate timestamps so they don't need to be rounded, so I'm going to try using that. adb shell ls -all drwxrwx--x 14 u0_a184 sdcard_rw 3488 2020-11-25 08:57:14.000000000 -0800 . |
I rewrote the timestamp parsing to use microseconds by cropping the nanos returned by ls -ll, and also using the UTC timestamp returned. I stoped using --times since it only sets low resolution timings via "adb touch" and it's slow, and the "adb push" uses to emulate copy already preserves modstamps. Then I added the modstamp tests on non-directories mentioned above, and fixed the "both" logic to skip copies off a newer modstamp. This all finally got adb-sync to sync files properly to the device. |
Since it's an underpinning of adb-sync, I looked into the behavior of adb push by itself on and Android 9 device and macOS. My understanding is that macOS emulates the Android file system where Linux/Win have native implementations. Looks like "adb push" if you pull the cable to the device in the middle of any push leaves a partial file with the current modstamp set as well. This means you have a partial copy of the file on the device, and since adb sync only checks modstamps, then it breaks our builds. Also if you push, touch a file, push again and cancel the push then the file is deleted. Wasn't expecting that either. Thought that the file system would still have that original file. push and cancel seems to not leave a file on the device either. Considering also adding a size check since the "ls -ll" command includes those too. At least it may be a checksum if there is correspondence between file sizes, and they're not thrown off by pagesize on the two file systems. |
We ended up dumping adb-sync except for excruciatingly slow deletes that are done one file at a time even if all the files under a folder are deleted. The general idea is as follows, and this is crazy fast and more safe than adb-sync.
|
I think this is due to self.both isn't processed for PerformCopies. I have a file with two lines that have the same length, where I comment out one line, and uncomment out another. Then I toggle this, and the file isn't copied. If I change the length of the lines, then src_only picks up the change.
This is with "adb-sync --delete --force ...". I also applied the "--times" fix in another issue, added --times, and fresh synced the content, but that still doesn't fix this issue on subsequent copies.
This self.both list seems to be created if the path on local matches the path on the remote, the stats aren't compared. But a copy is still needed if the modstamp differs. I only see self.both uses in overwrites and deletions, and not in the copy step. PerformCopies only walks the self_only list.
This means that the content on device is not correct, and doesn't reflect any mods that were made to the source directory. The modstamp, filesize, etc can all be different by adb-sync doesn't seem to check those. Please tell me I'm misreading something here, and that this important utility has been broken for all these years.
The following code could handle it, but skips if the file sizes match. But the content may be different (modstamps differ) even if the file size is the same. I'm assuming file padding is ignored from st_size. My understanding of overwrites is that they were meant to handle folders <-> files.
The text was updated successfully, but these errors were encountered: