Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.03k stars 10.01k forks source link

There is a bug in pushing files to the device #4876

Open zhangweildlh opened 3 weeks ago

zhangweildlh commented 3 weeks ago

Environment

Describe the bug Drag & drop non-APK file;Push file to device There is a bug in pushing files to the device

  1. Unable to push compressed files such as *. zip, prompt:"adb: error: failed to copy 'D:\Documents\Downloads\ABC.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory"
  2. After pushing a file with a long file name, the file name will be truncated, such as ABCDEFGHIJKLMNOPQ12345678.xlsx, which will be changed to ABCDEFGHIJKLMNO on the device

On errors, please provide the output of the console (and adb logcat if relevant).

Please paste terminal output in a code block.

Please do not post screenshots of your terminal, just post the content as text instead.

rom1v commented 3 weeks ago

What if you execute the exact same command with adb push manually?

adb push D:\Documents\Downloads\ABC.zip /sdcard/Download

? (or a file with a log file name)

zhangweildlh commented 3 weeks ago

adb push D:\Documents\Downloads\ABC.zip /sdcard/Download

Manually use adb Push execution to push the ABC.zip file to the mobile phone。

` D:\Tools\Scrcpy>adb devices

D:\Tools\Scrcpy>adb shell ls -lA /sdcard/Download ls: /sdcard/Download/微信临时缓存: Function not implemented ls: /sdcard/Download/企业微信: Function not implemented total 716627 -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh drwxrwxrwx 2 media_rw media_rw 3452 2024-04-12 20:04 Books -rwxrwxrwx 1 u0_a223 media_rw 312 2023-04-29 18:34 DelFiles.sh -rw-rw---- 1 u0_a223 media_rw 1020 2023-12-10 19:37 Find_and_DelFiles.sh drwxrws--- 3 u0_a223 media_rw 3452 2023-11-09 18:29 FuckVipHook -rw-rw---- 1 u0_a223 media_rw 29614 2024-04-04 09:08 HyperCeiler_settings_backup_2024-04-04-09_08_19.json -rw-rw---- 1 u0_a223 media_rw 1579 2024-01-20 21:25 Unix_To_Time.sh drwxrws--- 2 u0_a223 media_rw 3452 2024-04-17 19:05 WeiXin drwxrws--- 3 u0_a223 media_rw 3452 2024-04-22 07:57 com.lerist.fakelocation -rwxrwxrwx 1 u0_a223 media_rw 1392 2023-06-14 20:02 j2.sh -rwxrwxrwx 1 u0_a223 media_rw 1593 2021-11-09 15:40 test.sh -rwxrwx--- 1 root media_rw 90 2023-05-17 21:13 一键激活4.2.sh -rwxrwx--- 1 u0_a223 media_rw 2156805 2024-04-16 15:00 唐淼简历-2024-04.docx -rwxrwx--- 1 u0_a223 media_rw 3862540 2024-04-16 15:00 唐淼简历-2024-04.pdf -rwxrwx--- 1 root external_storage 134802 2023-02-23 11:08 峨眉政府及平台公司组织架构简图-2023-02.jpg -rw-rw---- 1 u0_a223 media_rw 22944 2023-12-31 11:44 微X模块_zhangwei_ldlh_2023-12-31_settings.json -rw-rw---- 1 u0_a223 media_rw 716465034 2023-04-07 18:22 民法-客观题【精讲卷】_众合法考_孟献贵讲义-2023.pdf drwxrws--- 2 u0_a223 media_rw 3452 2023-05-31 09:14 法考 -rwxrwx--- 1 u0_a223 media_rw 10371304 2024-04-17 17:25 爱玩机工具箱_S-22.0.8.7.apk

D:\Tools\Scrcpy>adb push D:\Documents\Downloads\ABC.zip /sdcard/Download D:\Documents\Downloads\ABC.zip: 1 file pushed, 0 skipped. 2.2 MB/s (14666 bytes in 0.006s)

D:\Tools\Scrcpy>adb shell ls -lA /sdcard/Download ls: /sdcard/Download/微信临时缓存: Function not implemented ls: /sdcard/Download/企业微信: Function not implemented total 716643 -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABC.zip -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh drwxrwxrwx 2 media_rw media_rw 3452 2024-04-12 20:04 Books -rwxrwxrwx 1 u0_a223 media_rw 312 2023-04-29 18:34 DelFiles.sh -rw-rw---- 1 u0_a223 media_rw 1020 2023-12-10 19:37 Find_and_DelFiles.sh drwxrws--- 3 u0_a223 media_rw 3452 2023-11-09 18:29 FuckVipHook -rw-rw---- 1 u0_a223 media_rw 29614 2024-04-04 09:08 HyperCeiler_settings_backup_2024-04-04-09_08_19.json -rw-rw---- 1 u0_a223 media_rw 1579 2024-01-20 21:25 Unix_To_Time.sh drwxrws--- 2 u0_a223 media_rw 3452 2024-04-17 19:05 WeiXin drwxrws--- 3 u0_a223 media_rw 3452 2024-04-22 07:57 com.lerist.fakelocation -rwxrwxrwx 1 u0_a223 media_rw 1392 2023-06-14 20:02 j2.sh -rwxrwxrwx 1 u0_a223 media_rw 1593 2021-11-09 15:40 test.sh -rwxrwx--- 1 root media_rw 90 2023-05-17 21:13 一键激活4.2.sh -rwxrwx--- 1 u0_a223 media_rw 2156805 2024-04-16 15:00 唐淼简历-2024-04.docx -rwxrwx--- 1 u0_a223 media_rw 3862540 2024-04-16 15:00 唐淼简历-2024-04.pdf -rwxrwx--- 1 root external_storage 134802 2023-02-23 11:08 峨眉政府及平台公司组织架构简图-2023-02.jpg -rw-rw---- 1 u0_a223 media_rw 22944 2023-12-31 11:44 微X模块_zhangwei_ldlh_2023-12-31_settings.json -rw-rw---- 1 u0_a223 media_rw 716465034 2023-04-07 18:22 民法-客观题【精讲卷】_众合法考_孟献贵讲义-2023.pdf drwxrws--- 2 u0_a223 media_rw 3452 2023-05-31 09:14 法考 -rwxrwx--- 1 u0_a223 media_rw 10371304 2024-04-17 17:25 爱玩机工具箱_S-22.0.8.7.apk

D:\Tools\Scrcpy>dir D:\Documents\Downloads\ABC.zip 驱动器 D 中的卷是 软件 卷的序列号是 8DA4-C9ED

D:\Documents\Downloads 的目录

2024-03-10 14:21 14,666 ABC.zip 1 个文件 14,666 字节 0 个目录 297,086,500,864 可用字节 ` 微信截图_20240424113114 微信截图_20240424113314

zhangweildlh commented 3 weeks ago

What if you execute the exact same command with adb push manually?

adb push D:\Documents\Downloads\ABC.zip /sdcard/Download

? (or a file with a log file name) Manually use the adb Push command to push files with long file names to the phone; for example, ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip success!

` D:\Tools\Scrcpy>adb shell ls -lA /sdcard/Download ls: /sdcard/Download/微信临时缓存: Function not implemented ls: /sdcard/Download/企业微信: Function not implemented total 716643 -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABC.zip -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh

D:\Tools\Scrcpy>adb push D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip /sdcard/Download D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip: 1 file pushed, 0 skipped. 58.2 MB/s (14666 bytes in 0.000s)

D:\Tools\Scrcpy>adb shell ls -lA /sdcard/Download ls: /sdcard/Download/微信临时缓存: Function not implemented ls: /sdcard/Download/企业微信: Function not implemented total 716659 -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABC.zip -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh

D:\Tools\Scrcpy>dir D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip 驱动器 D 中的卷是 软件 卷的序列号是 8DA4-C9ED

D:\Documents\Downloads 的目录

2024-03-10 14:21 14,666 ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip ` 微信截图_20240424114800

zhangweildlh commented 3 weeks ago

What if you execute the exact same command with adb push manually?

adb push D:\Documents\Downloads\ABC.zip /sdcard/Download

? (or a file with a log file name)

Pushing files to the phone in scrcpy.exe failed No.1 ABC.zip No.2 ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip No.3 正式版-规则整合 副本.zip (Chinese + space) scrcpy.exe -K --push-target=/storage/emulated/0/Download/

D:\Tools\Scrcpy>scrcpy.exe -K --push-target=/storage/emulated/0/Download/ scrcpy 2.4 <https://github.com/Genymobile/scrcpy> INFO: ADB device found: INFO: --> (usb) 208b0638 device 24031PN0DC D:\Tools\Scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 86.1 MB/s (69007 bytes in 0.001s) [server] INFO: Device: [Xiaomi] Xiaomi 24031PN0DC (Android 13) INFO: Renderer: direct3d INFO: Texture: 1080x2400 [server] WARN: Could not get initial audio timestamp INFO: Request to push D:\Documents\Downloads\ABC.zip INFO: Pushing D:\Documents\Downloads\ABC.zip... D:\Documents\Downloads\ABC.zip: 1 file pushed, 0 skipped. 42.2 MB/s (14666 bytes in 0.000s) adb: error: failed to copy 'D:\Documents\Downloads\ABC.zip' to '/storage/emulated/0/Download/ABC.zip': remote couldn't create file: No such file or directory ERROR: "adb push" returned with value 1 ERROR: Failed to push D:\Documents\Downloads\ABC.zip to /storage/emulated/0/Download/ INFO: Request to push D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip INFO: Pushing D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip... D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip: 1 file pushed, 0 skipped. 34.2 MB/s (14666 bytes in 0.000s) adb: error: failed to copy 'D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip' to '/storage/emulated/0/Download/ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip': remote couldn't create file: No such file or directory ERROR: "adb push" returned with value 1 ERROR: Failed to push D:\Documents\Downloads\ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890012345678900zxcvbnasd.zip to /storage/emulated/0/Download/ INFO: Request to push D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎 鍓湰.zip INFO: Pushing D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎 鍓湰.zip... D:\Documents\Downloads\正式版-规则整合 副本.zip: 1 file pushed, 0 skipped. 42.9 MB/s (14666 bytes in 0.000s) adb: error: failed to copy 'D:\Documents\Downloads\正式版-规则整合 副本.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory ERROR: "adb push" returned with value 1 ERROR: Failed to push D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎 鍓湰.zip to /storage/emulated/0/Download/ 微信截图_20240424115731

rom1v commented 3 weeks ago

scrcpy.exe -K --push-target=/storage/emulated/0/Download/

What is the result of:

adb push D:\Documents\Downloads\ABC.zip /storage/emulated/0/Download/

?

zhangweildlh commented 3 weeks ago

scrcpy.exe -K --push-target=/storage/emulated/0/Download/

What is the result of:

adb push D:\Documents\Downloads\ABC.zip /storage/emulated/0/Download/

?

Successfully pushed the ABC.zip file to mobile phone /storage/emulated/0/Download/ I tried two zip files, No.1 ABC.zip 14.3KB, No.2 DEF.zip 51.5MB; both were pushed successfully.

` D:\Tools\Scrcpy>adb push D:\Documents\Downloads\ABC.zip /storage/emulated/0/Download/

D:\Tools\Scrcpy>adb shell ls -l /storage/emulated/0/Download/ total 716643 -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABC.zip -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh drwxrwxrwx 2 media_rw media_rw 3452 2024-04-12 20:04 Books -rwxrwxrwx 1 u0_a223 media_rw 312 2023-04-29 18:34 DelFiles.sh

D:\Tools\Scrcpy>adb push D:\Documents\Downloads\DEF.zip /storage/emulated/0/Download/ D:\Documents\Downloads\DEF.zip: 1 file pushed, 0 skipped. 44.8 MB/s (54047897 bytes in 1.150s)

D:\Tools\Scrcpy>adb shell ls -l /storage/emulated/0/Download/ total 769483 -rw-rw---- 1 u0_a223 media_rw 14666 2024-03-10 14:21 ABC.zip -rwxrwxrwx 1 u0_a223 media_rw 6644 2023-08-11 14:44 Ad_Clean.sh drwxrwxrwx 2 media_rw media_rw 3452 2024-04-12 20:04 Books -rw-rw---- 1 u0_a223 media_rw 54047897 2024-04-22 19:01 DEF.zip -rwxrwxrwx 1 u0_a223 media_rw 312 2023-04-29 18:34 DelFiles.sh `

微信截图_20240424143048

rom1v commented 3 weeks ago

I don't understand, because scrcpy executes exactly this command. 🤔

rom1v commented 3 weeks ago

Please test with more logs:

diff --git a/app/src/adb/adb.c b/app/src/adb/adb.c
index 15c9c85a9..d669ed59d 100644
--- a/app/src/adb/adb.c
+++ b/app/src/adb/adb.c
@@ -317,6 +317,11 @@ sc_adb_push(struct sc_intr *intr, const char *serial, const char *local,
     const char *const argv[] =
         SC_ADB_COMMAND("-s", serial, "push", local, remote);

+    LOGI("[adb push]\n");
+    for (unsigned i = 0; i < ARRAY_LEN(argv); ++i) {
+        LOGI("=== [%u]: [%s]\n", i, argv[i]);
+    }
+
     sc_pid pid = sc_adb_execute(argv, flags);

 #ifdef __WINDOWS__

Here is a binary to replace in your scrcpy 2.4 folder:

zhangweildlh commented 3 weeks ago

scrcpy.exe -K --push-target=/storage/emulated/0/Download/

After replacing the scrcpy.exe you provided, execute scrcpy.exe -K --push-target=/storage/emulated/0/Download/

` D:\Tools\Scrcpy>scrcpy.exe -K --push-target=/storage/emulated/0/Download/ scrcpy 2.4 https://github.com/Genymobile/scrcpy

1 2

zhangweildlh commented 3 weeks ago

请使用更多日志进行测试:

diff --git a/app/src/adb/adb.c b/app/src/adb/adb.c
index 15c9c85a9..d669ed59d 100644
--- a/app/src/adb/adb.c
+++ b/app/src/adb/adb.c
@@ -317,6 +317,11 @@ sc_adb_push(struct sc_intr *intr, const char *serial, const char *local,
     const char *const argv[] =
         SC_ADB_COMMAND("-s", serial, "push", local, remote);

+    LOGI("[adb push]\n");
+    for (unsigned i = 0; i < ARRAY_LEN(argv); ++i) {
+        LOGI("=== [%u]: [%s]\n", i, argv[i]);
+    }
+
     sc_pid pid = sc_adb_execute(argv, flags);

 #ifdef __WINDOWS__

以下是要在 scrcpy 2.4 文件夹中替换的二进制文件:

  • scrcpy.exe SHA-256: ae6f6ca02a3d24a52810b16fc8b7361435d3d543199923331da6b9a1e55871c

微信截图_20240425104813

rom1v commented 3 weeks ago

ABC.zip

INFO: [adb push]
INFO: === [0]: [adb]
INFO: === [1]: [-s]
INFO: === [2]: [208b0638]
INFO: === [3]: [push]
INFO: === [4]: ["D:\Documents\Downloads\ABC.zip"]
INFO: === [5]: ["/storage/emulated/0/Download/"]
INFO: === [6]: [(null)]
D:\Documents\Downloads\ABC.zip: 1 file pushed,... skipped. 41.7 MB/s (54044899 bytes in 1.237s)
INFO: D:\Documents\Downloads\ABC.zip successfully pushed to /storage/emulated/0/Download/

This one worked.

正式版-规则整合.zip

INFO: [adb push]
INFO: === [0]: [adb]
INFO: === [1]: [-s]
INFO: === [2]: [208b0638]
INFO: === [3]: [push]
INFO: === [4]: ["D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎.zip"]
INFO: === [5]: ["/storage/emulated/0/Download/"]
INFO: === [6]: [(null)]
D:\Documents\Downloads\正式版-规则整合....d, 0 skipped. 6.6 MB/s (14666 bytes in 0.002s)
adb: error: failed to copy 'D:\Documents\Downloads\正式版-规则整合.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory

What is the result of:

adb -s 208b0638 push "D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎.zip" "/storage/emulated/0/Download/"

?


It seems the problem is with chinese characters. Probably #2184.

zhangweildlh commented 3 weeks ago

scrcpy.exe -K --push-target=/storage/emulated/0/Download/

I execute scrcpy.exe -K --push-target=/storage/emulated/0/Download/ Drag and drop 4 files to the phone mirror.

1、ABC.zip 2、书源校 验工具-v1.0.0 - 副本.zip 3、书源校验工具-v1.0.0.zip 4、CDE.zip 5、正式版 规则整合 - 副本.zip 6、正式版-规则整合.zip ` D:\Tools\Scrcpy>scrcpy.exe -K --push-target=/storage/emulated/0/Download/ scrcpy 2.4 https://github.com/Genymobile/scrcpy

`

1 2

zhangweildlh commented 3 weeks ago
adb -s 208b0638 push "D:\Documents\Downloads\姝e紡鐗?瑙勫垯鏁村悎.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\ABC.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\书源校 验工具-v1.0.0 - 副本.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\书源校验工具-v1.0.0.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\CDE.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\正式版 规则整合 - 副本.zip" "/storage/emulated/0/Download/"

adb -s 208b0638 push "D:\Documents\Downloads\正式版-规则整合.zip" "/storage/emulated/0/Download/"

` D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\ABC.zip" "/storage/emulated/0/Download/"

D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\书源校 验工具-v1.0.0 - 副本.zip" "/storage/emulated/0/Download/" adb: error: failed to copy 'D:\Documents\Downloads\书源校 验工具-v1.0.0 - 副本.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory D:\Documents\Downloads\书源校 验工具-v1.0.0 - 副本.zip: 1 file pushed, 0 skipped. 44.0 MB/s (54047897 bytes in 1.171s)

D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\书源校验工具-v1.0.0.zip" "/storage/emulated/0/Download/" D:\Documents\Downloads\书源校验工具-v1.0.0.zip: 1 file pushed, 0 skipped. 44.9 MB/s (54047897 bytes in 1.148s)

D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\CDE.zip" "/storage/emulated/0/Download/" adb: error: failed to copy 'D:\Documents\Downloads\CDE.zip' to '/storage/emulated/0/Download/CDE.zip': remote couldn't create file: No such file or directory D:\Documents\Downloads\CDE.zip: 1 file pushed, 0 skipped. 3.3 MB/s (14666 bytes in 0.004s)

D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\正式版 规则整合 - 副本.zip" "/storage/emulated/0/Download/" D:\Documents\Downloads\正式版 规则整合 - 副本.zip: 1 file pushed, 0 skipped. 11.3 MB/s (14666 bytes in 0.001s) adb: error: failed to copy 'D:\Documents\Downloads\正式版 规则整合 - 副本.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory

D:\Tools\Scrcpy>adb -s 208b0638 push "D:\Documents\Downloads\正式版-规则整合.zip" "/storage/emulated/0/Download/" D:\Documents\Downloads\正式版-规则整合.zip: 1 file pushed, 0 skipped. 25.4 MB/s (14666 bytes in 0.001s) adb: error: failed to copy 'D:\Documents\Downloads\正式版-规则整合.zip' to '/storage/emulated/0/Download/.': remote couldn't create file: Is a directory `

3

rom1v commented 3 weeks ago

OK, so you get the same behavior with adb alone (some files work, some files don't, maybe randomly). This is a problem in adb (maybe the adb server on your specific device).

Try (with adb alone) to push to /storage/emulated/0/Download rather than /storage/emulated/0/Download/ (maybe?).

Does it work on another device?

zhangweildlh commented 3 weeks ago

OK, so you get the same behavior with adb alone (some files work, some files don't, maybe randomly). This is a problem in adb (maybe the adb server on your specific device).

Try (with adb alone) to push to /storage/emulated/0/Download rather than /storage/emulated/0/Download/ (maybe?).

Does it work on another device?

I will start my vacation tomorrow, and after the vacation ends, I will try (with adb alone) to push to /storage/emulated/0/Download

I only have this one phone