google / adb-sync

Apache License 2.0
1.08k stars 169 forks source link

"bad date" from "touch" when using -t option #56

Open jgurling opened 3 years ago

jgurling commented 3 years ago

Hi, I'm trying to use adb-sync with the -t option to preserve file datestamps. Running on Ubuntu 20.04, connected to OnePlus 5 via USB. See code output below - seems like it's calling "touch" command which is taking issue with value (or format?) 20190103.103814. Is this an issue with adb-sync, or something on my end?

james@wagtail-fossa:~$ adb-sync -t ~/1p5\ backup\ 2021-06-18/DCIM/CameraTest /sdcard/DCIM/ INFO:root:Sync: local b'/home/james/1p5 backup 2021-06-18/DCIM/CameraTest', remote b'/sdcard/DCIM//CameraTest' INFO:root:Scanning and diffing... INFO:root:Push: b'/sdcard/DCIM//CameraTest/IMG_20190103_103812.jpg' /home/james/1p5 backup 2021-06-18/DCIM/CameraTest/IMG_20190...812.jpg: 1 file pushed. 20.2 MB/s (4110909 bytes in 0.194s) INFO:root:Push-Times: accessed Sat Jul 17 23:40:52 2021, modified Thu Jan 3 10:38:14 2019 touch: bad date 20190103.103814 INFO:root:Total: 7514 KB/s (4110909 bytes in 0.534s) Traceback (most recent call last): File "/home/james/.local/bin/adb-sync", line 883, in main() File "/home/james/.local/bin/adb-sync", line 877, in main syncer.PerformCopies() File "/home/james/.local/bin/adb-sync", line 646, in PerformCopies self.dst_fs[i].utime(dst_name, (s.st_atime, s.st_mtime)) File "/home/james/.local/bin/adb-sync", line 312, in utime raise OSError('touch failed') OSError: touch failed

altblue commented 2 years ago

Same here, because

adb shell 'touch --help' |grep -P '^-t'
-t  Set time to TIME (in [[CC]YY]MMDDhhmm[.ss][frac] format)

I monkey patched it by changing those two strftime templates accordingly:

time.strftime('%Y%m%d%H%M.%S'