Alist 无法获取 Azure Blob 的文件列表
- Lingua principale
- Go
- Stelle
- 50.2k
- Fork
- 7.9k
- Merge medio
- 7g 21h
- PR unite (30g)
- 6
Descrizione
最新更新:我在 ChatGPT 的指导下修正了这个 BUG,并且提交了一个 PR #9629
- - -
### Please make sure of the following things
- [x] I have read the [documentation](https://alistgo.com).
我已经阅读了[文档](https://alistgo.com)。
- [ ] I'm sure there are no duplicate issues or discussions.
我确定没有重复的issue或讨论。
- [x] I'm sure it's due to `AList` and not something else(such as [Network](https://alistgo.com/faq/howto.html#tls-handshake-timeout-read-connection-reset-by-peer-dns-lookup-failed-connect-connection-refused-client-timeout-exceeded-while-awaiting-headers-no-such-host) ,`Dependencies` or `Operational`).
我确定是`AList`的问题,而不是其他原因(例如[网络](https://alistgo.com/zh/faq/howto.html#tls-handshake-timeout-read-connection-reset-by-peer-dns-lookup-failed-connect-connection-refused-client-timeout-exceeded-while-awaiting-headers-no-such-host),`依赖`或`操作`)。
- [x] I'm sure this issue is not fixed in the latest version.
我确定这个问题在最新版本中没有被修复。
### AList Version / AList 版本
v3.63.0
### Driver used / 使用的存储驱动
Azure Blob
### Describe the bug / 问题描述
我与 [#8587](https://github.com/AlistGo/alist/issues/8587) 遇到了同样的问题:连接 Azure Blob Storage 的指定 container 成功,能够成功上传文件/新建文件夹,但是无法显示文件列表;刚从 AList 上传的文件也无法显示,但是Azure 上确实已有该文件,说明上传成功。直接用的 access key,应该不存在读权限问题。
————
我在 ChatGPT 的指导下,发现了这个问题在于 Alist 的源码错误地把 `/` (斜杠)作为 Blob 文件的 prefix,从而在列出文件时返回 0 个文件。
**以下是 ChatGPT 的分析结果**:
AList Azure Blob 驱动的 `List()` 函数里面有:
```Go
prefix := ensureTrailingSlash(dir.GetPath())
pager := d.containerClient.NewListBlobsHierarchyPager("/", &container.ListBlobsHierarchyOptions{
Prefix: &prefix,
})
```
也就是说:AList 会把当前目录路径转换成 `prefix`,然后把这个 `prefix` 交给 Azure 的 `ListBlobsHierarchy`。
而 `ensureTrailingSlash()` 是:
```Go
func ensureTrailingSlash(path string) string {
if !strings.HasSuffix(path, "/") {
return path + "/"
}
return path
}
```
我的 Alist 当前正在访问 `/Azure_Blob_1_(K)/` 也就是 Azure Container 的根目录,Alist 的根对象路径实际上是 `/`。经过 `ensureTrailingSlash("/")` 以后仍然是 '/'。于是 AList 最终实际上是在告诉 Azure:请列出 Blob 名称以 / 开头的文件。
但我的 Azure Blob 中的文件没有一个是以 `/` 开头,所以 Azure 按照 Prefix `/` 进行过滤后,结果当然就是 0 个 Blob。
————
希望开发者在源码中修正这个错误。
### Reproduction / 复现链接
复现链接:https://netdisk.kukmoon.com/Azure_Blob_2_(K) (如图 1)
因为我已经向对应的 Azure Blob 中上传了一个文件(如图 2),所以图 1 显示的此处不应该是空白。
### Config / 配置
{
"id": 6,
"mount_path": "/Azure_Blob_2_(K)",
"order": 6,
"driver": "Azure Blob Storage",
"cache_expiration": 30,
"status": "work",
"addition": "{\"endpoint\":\"https://kukmoonoutlookcom.blob.core.windows.net/\",\"access_key\":\"《My Access Key》\",\"container_name\":\"bucket1\",\"sign_url_expire\":4}",
"remark": "",
"modified": "2026-08-16T12:30:46.803402548+08:00",
"disabled": false,
"disable_index": false,
"enable_sign": false,
"order_by": "",
"order_direction": "",
"extract_folder": "",
"web_proxy": false,
"webdav_policy": "302_redirect",
"proxy_range": false,
"down_proxy_url": "",
"down_proxy_sign": true
}
### Logs / 日志
[GIN] 2026/08/23 - 10:11:52 | 200 | 752.181µs | 112.8.51.43 | POST "/api/fs/dirs"
[GIN] 2026/08/23 - 10:11:53 | 200 | 450.347678ms | 112.8.51.43 | POST "/api/fs/dirs"
[GIN] 2026/08/23 - 10:11:53 | 200 | 722.575µs | 112.8.51.43 | POST "/api/fs/dirs"
[GIN] 2026/08/23 - 10:11:53 | 200 | 1.524278ms | 112.8.51.43 | POST "/api/admin/role/update"
[GIN] 2026/08/23 - 10:11:54 | 200 | 792.176µs | 112.8.51.43 | GET "/api/admin/role/list"
[GIN] 2026/08/23 - 10:12:04 | 200 | 604.493µs | 35.212.205.65 | GET "/api/me"
[GIN] 2026/08/23 - 10:12:05 | 200 | 110.046µs | 35.212.205.65 | GET "/assets/index-ccd3c2df.js"
[GIN] 2026/08/23 - 10:12:05 | 200 | 110.507µs | 35.212.205.65 | GET "/assets/Profile-e8195cc8.js"
[GIN] 2026/08/23 - 10:12:05 | 200 | 1.859888ms | 35.212.205.65 | GET "/api/me/sshkey/list"
[GIN] 2026/08/23 - 10:12:07 | 200 | 573.746µs | 35.212.205.65 | GET "/api/auth/logout"
[GIN] 2026/08/23 - 10:12:07 | 200 | 552.236µs | 35.212.205.65 | GET "/api/public/settings"
[GIN] 2026/08/23 - 10:12:08 | 200 | 637.426µs | 35.212.205.65 | GET "/api/me"
[GIN] 2026/08/23 - 10:12:08 | 200 | 582.122µs | 35.212.205.65 | GET "/api/me/sshkey/list"
[GIN] 2026/08/23 - 10:12:09 | 200 | 564.058µs | 35.212.205.65 | GET "/api/me"
[GIN] 2026/08/23 - 10:12:09 | 200 | 340.607µs | 35.212.205.65 | GET "/api/public/offline_download_tools"
[GIN] 2026/08/23 - 10:12:12 | 200 | 61.285µs | 35.212.205.65 | GET "/"
[GIN] 2026/08/23 - 10:12:12 | 200 | 72.586µs | 35.212.205.65 | GET "/api/public/settings"
[GIN] 2026/08/23 - 10:12:12 | 200 | 71.064µs | 35.212.205.65 | GET "/api/public/archive_extensions"
[GIN] 2026/08/23 - 10:12:13 | 200 | 589.035µs | 35.212.205.65 | GET "/api/me"
[GIN] 2026/08/23 - 10:12:13 | 200 | 610.084µs | 35.212.205.65 | GET "/api/label/list"
[GIN] 2026/08/23 - 10:12:13 | 200 | 296.054µs | 35.212.205.65 | GET "/api/public/offline_download_tools"
[GIN] 2026/08/23 - 10:12:14 | 200 | 108.914918ms | 35.212.205.65 | POST "/api/fs/list"
[GIN] 2026/08/23 - 10:14:00 | 200 | 792.456µs | 112.8.51.43 | POST "/api/fs/list"
[GIN] 2026/08/23 - 10:14:09 | 200 | 680.957µs | 112.8.51.43 | GET "/api/admin/driver/names"
[GIN] 2026/08/23 - 10:14:09 | 200 | 884.959µs | 112.8.51.43 | GET "/api/admin/storage/list"
[GIN] 2026/08/23 - 10:14:11 | 200 | 655.89µs | 112.8.51.43 | GET "/api/admin/storage/get?id=6"
[GIN] 2026/08/23 - 10:14:12 | 200 | 636.774µs | 112.8.51.43 | GET "/api/admin/driver/info?driver=Azure%20Blob%20Storage"
[GIN] 2026/08/23 - 10:16:29 | 200 | 2.993503ms | 112.8.51.43 | GET "/api/admin/setting/list"
[GIN] 2026/08/23 - 10:16:30 | 200 | 854.632µs | 112.8.51.43 | GET "/api/admin/user/list"
[GIN] 2026/08/23 - 10:16:30 | 200 | 987.842µs | 112.8.51.43 | GET "/api/admin/storage/list"
[GIN] 2026/08/23 - 10:16:31 | 200 | 759.264µs | 112.8.51.43 | GET "/api/admin/meta/list"
[GIN] 2026/08/23 - 10:16:31 | 200 | 690.836µs | 112.8.51.43 | GET "/api/label/list"
[GIN] 2026/08/23 - 10:16:31 | 200 | 714.419µs | 112.8.51.43 | GET "/api/admin/label_file_binding/list"
[GIN] 2026/08/23 - 10:16:32 | 200 | 935.184µs | 112.8.51.43 | GET "/api/admin/role/list"
[GIN] 2026/08/23 - 10:25:18 | 200 | 440.600684ms | 112.8.51.43 | POST "/api/fs/list"
[GIN] 2026/08/23 - 10:25:19 | 200 | 55.865µs | 112.8.51.43 | GET "/Azure_Blob_2_(K)"
[GIN] 2026/08/23 - 10:25:20 | 200 | 84.647µs | 112.8.51.43 | GET "/api/public/settings"
[GIN] 2026/08/23 - 10:25:20 | 200 | 23.274µs | 112.8.51.43 | GET "/api/public/archive_extensions"
[GIN] 2026/08/23 - 10:25:21 | 200 | 589.165µs | 112.8.51.43 | GET "/api/me"
[GIN] 2026/08/23 - 10:25:21 | 200 | 775.705µs | 112.8.51.43 | GET "/api/label/list"
[GIN] 2026/08/23 - 10:25:21 | 200 | 662.533µs | 112.8.51.43 | POST "/api/fs/get"
[GIN] 2026/08/23 - 10:25:21 | 200 | 249.898µs | 112.8.51.43 | GET "/api/public/offline_download_tools"
[GIN] 2026/08/23 - 10:25:22 | 200 | 109.049631ms | 112.8.51.43 | POST "/api/fs/list"
[GIN] 2026/08/23 - 10:25:24 | 200 | 149.821µs | 112.8.51.43 | GET "/Azure_Blob_2_(K)"
[GIN] 2026/08/23 - 10:25:25 | 200 | 82.665µs | 112.8.51.43 | GET "/api/public/settings"
[GIN] 2026/08/23 - 10:25:25 | 200 | 21.34µs | 112.8.51.43 | GET "/api/public/archive_extensions"
[GIN] 2026/08/23 - 10:25:25 | 200 | 603.982µs | 112.8.51.43 | GET "/api/me"
[GIN] 2026/08/23 - 10:25:26 | 200 | 626.736µs | 112.8.51.43 | GET "/api/label/list"
[GIN] 2026/08/23 - 10:25:26 | 200 | 550.673µs | 112.8.51.43 | POST "/api/fs/get"
[GIN] 2026/08/23 - 10:25:26 | 200 | 215.434µs | 112.8.51.43 | GET "/api/public/offline_download_tools"
[GIN] 2026/08/23 - 10:25:27 | 200 | 109.414385ms | 112.8.51.43 | POST "/api/fs/list"
[GIN] 2026/08/23 - 10:25:28 | 200 | 74.009µs | 112.8.51.43 | GET "/Azure_Blob_2_(K)"
[GIN] 2026/08/23 - 10:25:30 | 200 | 38.953µs | 112.8.51.43 | GET "/api/public/archive_extensions"
[GIN] 2026/08/23 - 10:25:30 | 200 | 80.631µs | 112.8.51.43 | GET "/api/public/settings"
[GIN] 2026/08/23 - 10:25:31 | 200 | 586.008µs | 112.8.51.43 | GET "/api/me"
[GIN] 2026/08/23 - 10:25:31 | 200 | 663.122µs | 112.8.51.43 | GET "/api/label/list"
[GIN] 2026/08/23 - 10:25:31 | 200 | 276.077µs | 112.8.51.43 | GET "/api/public/offline_download_tools"
[GIN] 2026/08/23 - 10:25:31 | 200 | 545.333µs | 112.8.51.43 | POST "/api/fs/get"
[GIN] 2026/08/23 - 10:25:32 | 200 | 109.754184ms | 112.8.51.43 | POST "/api/fs/list"
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.