Skip to content

debug: 添加调试日志,输出到外置存储#25

Closed
sisterfuture wants to merge 6 commits into
masterfrom
debug/ftp-upload-issue
Closed

debug: 添加调试日志,输出到外置存储#25
sisterfuture wants to merge 6 commits into
masterfrom
debug/ftp-upload-issue

Conversation

@sisterfuture

Copy link
Copy Markdown
Collaborator

调试目的

解决未来姐姐 ftpFileWrite 工具向太极 FTP 服务器上传文件失败的问题。

错误信息: Truncated server reply: '150 ' (MalformedServerReplyException)

新增调试功能

  1. 外置存储日志 - 路径格式: /sdcard/Download/builtinftp_<包名>_debug.log
    • 包含包名可避免多应用日志冲突
    • 如:builtinftp_com.stupidbeauty.hxftpserver_debug.log
  2. FTP 命令/响应记录 - logFtpCommand()logFtpReply()
  3. STOR 命令 150 响应改进 - 包含文件名,便于定位问题

调试步骤

  1. 构建此版本 APK
  2. 在小米手机上安装并启动 FTP 服务器
  3. 使用未来姐姐 ftpFileWrite 工具上传文件(应失败)
  4. 读取对应的调试日志文件分析失败原因

待解决

  • 需要确认服务器发送的 150 响应格式是否被客户端正确解析

新增功能:
1. getDebugLogFilePath() - 获取调试日志路径(包含包名,避免多应用冲突)
   格式: /sdcard/Download/builtinftp_<包名>_debug.log
2. writeDebugLog() - 写入调试日志到外置存储
3. logFtpCommand() - 记录所有 FTP 命令
4. logFtpReply() - 记录所有 FTP 响应
5. processStorCommand() 中改进 150 响应消息,便于调试

调试信息包括:
- FTP 命令接收
- FTP 响应发送(特别是 STOR 命令的 150 响应)
- 文件上传进度
- 错误信息

注意:日志文件路径包含包名,如:
- 太极FTP应用: builtinftp_com.stupidbeauty.hxftpserver_debug.log
- 未来姐姐: builtinftp_com.stupidbeauty.sisterfuture_debug.log
这样可以避免多应用日志冲突。
仅在以下位置添加调试日志:
1. processStorCommand() - 记录 STOR 命令处理
2. processCommand() - 记录所有命令
3. receiveDataSocket() - 记录数据接收
4. handleDataAccept() - 记录数据连接
5. finishFileWrite() - 记录文件关闭

日志路径包含包名避免多应用冲突:
/sdcard/Download/builtinftp_<包名>_debug.log
@hxcan hxcan closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants