Skip to content

Error when file modification dates are old #54

@rch7

Description

@rch7

It has problem with old file modification dates. E.g.

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          1/6/1929  12:00 AM        3813558 1929-01-06-1 - ***********************************.jpg
[INFO] Copying copy tree
C:\Nuotraukos\Senos2\1929-01-06-1 - ***********************************..jpg: 1 file pushed, 0 skipped. 20.1 MB/s (3813558 bytes in 0.181s)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\rch\AppData\Roaming\Python\Python313\Scripts\adbsync.exe\__main__.py", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\rch\AppData\Roaming\Python\Python313\site-packages\BetterADBSync\__init__.py", line 510, in main
    fs_destination.push_tree_here(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        path_source,
        ^^^^^^^^^^^^
    ...<5 lines>...
        show_progress = args.show_progress
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\rch\AppData\Roaming\Python\Python313\site-packages\BetterADBSync\FileSystems\Base.py", line 91, in push_tree_here
    self.push_tree_here(
    ~~~~~~~~~~~~~~~~~~~^
        fs_source.normpath(fs_source.join(tree_path, key)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
        show_progress = show_progress
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\rch\AppData\Roaming\Python\Python313\site-packages\BetterADBSync\FileSystems\Base.py", line 91, in push_tree_here
    self.push_tree_here(
    ~~~~~~~~~~~~~~~~~~~^
        fs_source.normpath(fs_source.join(tree_path, key)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
        show_progress = show_progress
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\rch\AppData\Roaming\Python\Python313\site-packages\BetterADBSync\FileSystems\Base.py", line 81, in push_tree_here
    self.utime(destination_root, tree)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rch\AppData\Roaming\Python\Python313\site-packages\BetterADBSync\FileSystems\Android.py", line 184, in utime
    mtime = datetime.datetime.fromtimestamp(times[1]).strftime("%Y%m%d%H%M")
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
OSError: [Errno 22] Invalid argument

The resulting file is created with 2106-02-07 01:28 date. You can set old dates in Android through adb, e.g.:

PS C:\Users\rch> C:\SamFwTool\data\adb.exe shell touch -d 1929-01-06 '/storage/emulated/0/Nuotraukos/Senos2/1929-01-06*'
PS C:\Users\rch> C:\SamFwTool\data\adb.exe shell ls -l '/storage/emulated/0/Nuotraukos/Senos2/1929-01-06*'
-rw-rw---- 1 u0_a263 media_rw 3813558 1929-01-06 00:00 /storage/emulated/0/Nuotraukos/Senos2/1929-01-06-1 - **********************.jpg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions