messense / aliyundrive-webdav

阿里云盘 WebDAV 服务
MIT License
9.62k stars 1.09k forks source link

windows下路径分隔符导致的文件404 #302

Closed Greyh4t closed 2 years ago

Greyh4t commented 2 years ago

问题描述

windows下默认的路径分隔符为\,在windows下,使用root参数时,拼接后的路径中包含反斜杠,通过阿里云接口查询文件时,会返回404,同样的命令linux下测试没问题

重现步骤

  1. 确保阿里云盘存在 /movies/星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9/SE01(15集)1080P/S01E01.mp4 文件
  2. 在windows上启动服务 ./aliyundrive-webdav -I --cache-ttl 30 --host 127.0.0.1 -p 5005 --root /movies -w ./ -r <token>
  3. 访问文件 curl -i http://127.0.0.1:5005/%E6%98%9F%E9%99%85%E8%BF%B7%E8%88%AA%EF%BC%9A%E5%8F%91%E7%8E%B0%E5%8F%B71080P_1-4%E5%AD%A3_%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%EF%BC%882017%EF%BC%89%E3%80%90%E7%BE%8E%E5%89%A7%E3%80%91%E8%B1%86%E7%93%A3%E8%AF%84%E5%88%86%EF%BC%9A7.9/SE01%EF%BC%8815%E9%9B%86%EF%BC%891080P/S01E01.mp4
  4. 返回404

版本

v1.2.4

运行平台

Windows

日志

2022-02-15T12:18:19.907055Z  INFO aliyundrive_webdav::drive: found default drive drive_id=23078150
2022-02-15T12:18:19.907904Z DEBUG aliyundrive_webdav::vfs: dir cache initialized
2022-02-15T12:18:19.908184Z DEBUG aliyundrive_webdav: aliyundrive file system initialized
2022-02-15T12:18:19.908414Z DEBUG aliyundrive_webdav: webdav handler initialized read_buffer_size=10485760 auto_index=true
2022-02-15T12:18:19.908939Z  INFO aliyundrive_webdav: listening on http://127.0.0.1:5005
2022-02-15T12:18:38.822792Z DEBUG aliyundrive_webdav::vfs: fs: metadata path=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9/SE01(15集)1080P/S01E01.mp4
2022-02-15T12:18:38.823045Z TRACE aliyundrive_webdav::cache: cache: get key=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9/SE01(15集)1080P
2022-02-15T12:18:38.823277Z TRACE aliyundrive_webdav::vfs: file not found in cache path=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9/SE01(15集)1080P/S01E01.mp4
2022-02-15T12:18:38.823484Z DEBUG aliyundrive_webdav::drive: get file by path drive_id=23078150 path=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9/SE01(15集)1080P/S01E01.mp4
2022-02-15T12:18:38.975916Z DEBUG aliyundrive_webdav::vfs: read_dir and cache path=/
2022-02-15T12:18:38.976195Z TRACE aliyundrive_webdav::cache: cache: get key=/
2022-02-15T12:18:38.976403Z DEBUG aliyundrive_webdav::drive: list file drive_id=23078150 parent_file_id=root marker=None
2022-02-15T12:18:39.084176Z TRACE aliyundrive_webdav::vfs: cache dir path=/ count=1
2022-02-15T12:18:39.084455Z TRACE aliyundrive_webdav::cache: cache: insert key=/
2022-02-15T12:18:39.084676Z DEBUG aliyundrive_webdav::vfs: read_dir and cache path=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9
2022-02-15T12:18:39.084903Z TRACE aliyundrive_webdav::cache: cache: get key=/movies
2022-02-15T12:18:39.085122Z DEBUG aliyundrive_webdav::drive: get file by path drive_id=23078150 path=/movies\星际迷航:发现号1080P_1-4季_持续更新(2017)【美剧】豆瓣评分:7.9
Greyh4t commented 2 years ago

这个bug会导致在windows上用rclone挂载webdav的时候,无法观看挂载盘里的视频。视频刚打开可以播放,播放一会儿就不能播了,同时rclone会报大量的404错误。查日志发现就是aliyundrive-webdav返回了404导致的,复现有两个条件:

  1. 在aliyundrive-webdav中指定了root参数,并且值不是/,而是/movies或其他非/的路径
  2. rclone挂载的路径使用/,例如 rclone.exe mount aliyun:/ D:\movies\aliyun_webdav --vfs-cache-mode writes

挂载好后播放D:\movies\aliyun_webdav中的视频,播一会儿就会出现问题

临时的解决方案是rclone中的挂载路径确保与root参数一致,如rclone.exe mount aliyun:/movies D:\movies\aliyun_webdav --vfs-cache-mode writes。但是这个方案逻辑上是不合理的,正常来说指定了root参数为/movies之后,访问/就代表访问网盘中的/movies,所以挂载rclone中应该指定为/,而不是/movies @messense 大佬能修复一下吗

messense commented 2 years ago

暂时没有 Windows 设备可以复现问题和测试,修复得先等一等了。

Greyh4t commented 2 years ago

暂时没有 Windows 设备可以复现问题和测试,修复得先等一等了。

好的,谢谢大佬,那我先用临时方案

messense commented 2 years ago

@Greyh4t 等 https://github.com/messense/aliyundrive-webdav/actions/runs/1871683316 这个跑完了可以下载下编译好的二进制文件确认一下是否已经修复。

Greyh4t commented 2 years ago

@messense 测试了,已经修复了,感谢!