-
Notifications
You must be signed in to change notification settings - Fork 183
adb-sync doesn't copy files properly if names are same on local and remote #50
Description
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.
BuildFileLists
this creates List[Tuple[path, stats]]
def DiffLists(...)
if a_item[0] == b_item[0]: <- seems to only compare the path portion of the tuple from BuildFileLists, should this be comparing a_item[1] == b_item[1], and same on two calls below
both.append((a_item[0], a_item[1], b_item[1]))
a_revlist.pop()
b_revlist.pop()
elif a_item[0] < b_item[0]:
a_only.append(a_item)
a_revlist.pop()
elif a_item[0] > b_item[0]:
b_only.append(b_item)
b_revlist.pop()
else:
def PerformCopies(self) -> None:
"""Perform all copying necessary for the file sync operation."""
for i in [0, 1]:
if self.src_to_dst[i]:
for name, s in self.src_only[i]: <- this is only walking the src_only list build from DiffLists, self.both is ignored
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.
def PerformOverwrites(self) -> None:
for name, localstat, remotestat in self.both: <- okay this walks the both list
if stat.S_ISDIR(localstat.st_mode) and stat.S_ISDIR(remotestat.st_mode):
# A dir is a dir is a dir.
continue
elif stat.S_ISDIR(localstat.st_mode) or stat.S_ISDIR(remotestat.st_mode):
# Dir vs file? Nothing to do here yet.
pass
else:
# File vs file? Compare sizes.
if localstat.st_size == remotestat.st_size: <- this earlies out off file size
continue