Repository: AlistGo/alist (language: go)

Issue:
TeraBox download error
### Please make sure of the following things

- [X] I have read the [documentation](https://alist.nn.ci).
- [X] I'm sure there are no duplicate issues or discussions.
- [X] I'm sure it's due to `alist` and not something else(such as `Dependencies` or `Operational`).
- [X] I'm sure I'm using the latest version

### Alist Version / Alist 版本

v3.23.0

### Driver used / 使用的存储驱动

TeraBox 

### Describe the bug / 问题描述

302
Download error:
![328C63F9-B133-46F6-8595-798BB2295A38](https://github.com/alist-org/alist/assets/83632110/311a1c91-3c55-4571-8549-f6af4ced8e1a)


### Reproduction / 复现链接

Official api

### Logs / 日志

![28F01EEF-07CB-4375-89C5-799686DB5854](https://github.com/alist-org/alist/assets/83632110/9686474b-0a8f-4ff7-930e-3e001ce2ddcb)



Discussion / hints:
提示：`Request failed with status code 500` 错误码

## 完整日志如下
[log.log-可下载查看也可以在线查看](https://github.com/alist-org/alist/files/12190245/log.log)

```txt
[GIN] 2023/07/28 - 12:37:22 | 200 |            0s |       127.0.0.1 | GET      "/本地"
[GIN] 2023/07/28 - 12:37:33 | 200 |            0s |       127.0.0.1 | GET      "/Terabox"
[37mDEBU[0m[2023-07-28 12:37:34]/source/server/middlewares/auth.go:66 github.com/alist-org/alist/v3/server/middlewares.Auth() use login token: &{ID:1 Username:admin Password:admin BasePath:/ Role:2 Disabled:false Permission:0 OtpSecret: SsoID:d0573b05-6ba0-47af-90d3-60bd8f294323} 

2023/07/28 12:37:34 [32m/source/internal/db/meta.go:10
[0m[33m[0.000ms] [34;1m[rows:0][0m SELECT * FROM `x_meta` WHERE `x_meta`.`path` = "/Terabox" ORDER BY `x_meta`.`id` LIMIT 1
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/fs.go:101 github.com/alist-org/alist/v3/internal/op.List() op.List /                                    
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/fs.go:160 github.com/alist-org/alist/v3/internal/op.Get() op.Get /                                     
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/fs.go:113 github.com/alist-org/alist/v3/internal/op.List() list dir: &{ID: Path:/ Name:root Size:0 Modified:2023-07-28 11:23:07.381303 +0800 +0800 IsFolder:true} 
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/fs.go:145 github.com/alist-org/alist/v3/internal/op.List.func1() set cache: /Terabox => [0xc0007bd540 0xc0007bd560] 
[37mDEBU[0m[2023-07-28 12:37:34]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[GIN] 2023/07/28 - 12:37:34 | 200 |    811.0464ms |       127.0.0.1 | POST     "/api/fs/list"
[GIN] 2023/07/28 - 12:37:36 | 200 |            0s |       127.0.0.1 | GET      "/Terabox/IPA"
[37mDEBU[0m[2023-07-28 12:37:37]/source/server/middlewares/auth.go:66 github.com/alist-org/alist/v3/server/middlewares.Auth() use login token: &{ID:1 Username:admin Password:admin BasePath:/ Role:2 Disabled:false Permission:0 OtpSecret: SsoID:d0573b05-6ba0-47af-90d3-60bd8f294323} 

2023/07/28 12:37:37 [32m/source/internal/db/meta.go:10
[0m[33m[0.000ms] [34;1m[rows:0][0m SELECT * FROM `x_meta` WHERE `x_meta`.`path` = "/Terabox/IPA" ORDER BY `x_meta`.`id` LIMIT 1
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:101 github.com/alist-org/alist/v3/internal/op.List() op.List /IPA                                 
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:160 github.com/alist-org/alist/v3/internal/op.Get() op.Get /IPA                                  
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:101 github.com/alist-org/alist/v3/internal/op.List() op.List /                                    
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:105 github.com/alist-org/alist/v3/internal/op.List() use cache when list /                        
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:113 github.com/alist-org/alist/v3/internal/op.List() list dir: &{Object:{ID:63379289620761 Path:/IPA Name:IPA Size:0 Modified:2023-06-23 21:44:51 +0800 CST IsFolder:true} Thumbnail:{Thumbnail:}} 
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/fs.go:145 github.com/alist-org/alist/v3/internal/op.List.func1() set cache: /Terabox/IPA => [0xc000981a60 0xc000981a80 0xc000981aa0] 
[37mDEBU[0m[2023-07-28 12:37:37]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[GIN] 2023/07/28 - 12:37:37 | 200 |    384.0219ms |       127.0.0.1 | POST     "/api/fs/list"
[37mDEBU[0m[2023-07-28 12:37:39]/source/server/middlewares/auth.go:66 github.com/alist-org/alist/v3/server/middlewares.Auth() use login token: &{ID:1 Username:admin Password:admin BasePath:/ Role:2 Disabled:false Permission:0 OtpSecret: SsoID:d0573b05-6ba0-47af-90d3-60bd8f294323} 

2023/07/28 12:37:39 [32m/source/internal/db/meta.go:10
[0m[33m[0.000ms] [34;1m[rows:0][0m SELECT * FROM `x_meta` WHERE `x_meta`.`path` = "/Terabox/IPA/nPlayerPlus.ipa" ORDER BY `x_meta`.`id` LIMIT 1
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:160 github.com/alist-org/alist/v3/internal/op.Get() op.Get /IPA/nPlayerPlus.ipa                  
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:101 github.com/alist-org/alist/v3/internal/op.List() op.List /IPA                                 
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:105 github.com/alist-org/alist/v3/internal/op.List() use cache when list /IPA                     
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/path.go:25 github.com/alist-org/alist/v3/internal/op.GetStorageAndActualPath() use storage:  /Terabox                       
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:160 github.com/alist-org/alist/v3/internal/op.Get() op.Get /IPA/nPlayerPlus.ipa                  
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:101 github.com/alist-org/alist/v3/internal/op.List() op.List /IPA                                 
[37mDEBU[0m[2023-07-28 12:37:39]/source/internal/op/fs.go:105 github.com/alist-org/alist/v3/internal/op.List() use cache when list /IPA                     


[31m2023/07/28 12:37:39 [Recovery] 2023/07/28 - 12:37:39 panic recovered:
POST /api/fs/get HTTP/1.1
Host: 127.0.0.1:5244
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,de;q=0.7,ja;q=0.6
Authorization: *
Connection: keep-alive
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cookie: casdoor_session_id=64d37cc46ca1d557f273e19557f69512
Origin: http://127.0.0.1:5244
Referer: http://127.0.0.1:5244/Terabox/IPA
Sec-Ch-Ua: "Not-A.Brand";v="24", "Chromium";v="14"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.125 Safari/537.36


runtime error: index out of range [0] with length 0

runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/alist-org/alist/v3/pkg/singleflight.newPanicError({0x1876380?, 0xc000d16930})
	/source/pkg/singleflight/singleflight.go:35 +0x2c
github.com/alist-org/alist/v3/pkg/singleflight.(*Group[...]).doCall.func2.1()
	/source/pkg/singleflight/singleflight.go:188 +0x3b
panic({0x1876380, 0xc000d16930})
	/usr/local/go/src/runtime/panic.go:884 +0x213
github.com/alist-org/alist/v3/drivers/terabox.(*Terabox).linkOfficial(0xc0002e4500, {0x23d2178, 0xc0001d2e70}, {{0xc0008c7400, 0x9}, 0xc000dec300, {0x0, 0x0}, 0xc000bf0b00})
	/source/drivers/terabox/util.go:142 +0x950
github.com/alist-org/alist/v3/drivers/terabox.(*Terabox).Link(0xc000b9edf8?, {0x21f3ca?, 0xc000d817a0?}, {0x23d2178?, 0xc0001d2e70?}, {{0xc0008c7400, 0x9}, 0xc000dec300, {0x0, 0x0}, ...})
	/source/drivers/terabox/driver.go:69 +0xb6
github.com/alist-org/alist/v3/internal/op.Link.func1()
	/source/internal/op/fs.go:251 +0x63
github.com/alist-org/alist/v3/pkg/singleflight.(*Group[...]).doCall.func2(0xc0002857c0, 0xd0, 0x1817280?)
	/source/pkg/singleflight/singleflight.go:193 +0x71
github.com/alist-org/alist/v3/pkg/singleflight.(*Group[...]).doCall(0xc000decb70?, 0xc000da73b0?, {0xc000da73b0?, 0x6dfb17?}, 0xc000206b00?)
	/source/pkg/singleflight/singleflight.go:195 +0xac
github.com/alist-org/alist/v3/pkg/singleflight.(*Group[...]).Do(0x23f1580, {0xc000da73b0, 0x26}, 0xc000d81408)
	/source/pkg/singleflight/singleflight.go:108 +0x179
github.com/alist-org/alist/v3/internal/op.Link({0x23cf1a8, 0xc0008ef100}, {0x23d70b8?, 0xc0002e4500?}, {0xc000d81408, 0x14}, {{0xc0008c7400, 0x9}, 0xc000dec300, {0x0, ...}, ...})
	/source/internal/op/fs.go:260 +0x409
github.com/alist-org/alist/v3/internal/fs.link({0x23cf1a8?, 0xc0008ef100}, {0xc000d81400?, 0x1?}, {{0xc0008c7400, 0x9}, 0xc000dec300, {0x0, 0x0}, 0xc000bf0b00})
	/source/internal/fs/link.go:19 +0x110
github.com/alist-org/alist/v3/internal/fs.Link({0x23cf1a8?, 0xc0008ef100?}, {0xc000d81400, 0x1c}, {{0xc0008c7400, 0x9}, 0xc000dec300, {0x0, 0x0}, 0xc000bf0b00})
	/source/internal/fs/fs.go:48 +0x71
github.com/alist-org/alist/v3/server/handles.FsGet(0xc0008ef100)
	/source/server/handles/fsread.go:289 +0x79b
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/alist-org/alist/v3/server/middlewares.Auth(0xc0008ef100)
	/source/server/middlewares/auth.go:67 +0x4e8
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/alist-org/alist/v3/server/middlewares.StoragesLoaded(0xc0008ef100)
	/source/server/middlewares/check.go:14 +0xae
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc0008ef100)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 +0x82
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.LoggerWithConfig.func1(0xc0008ef100)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 +0xe7
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc0008ce1a0, 0xc0008ef100)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 +0x66b
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc0008ce1a0, {0x23cd570?, 0xc000dfa1c0}, 0xc000bf0b00)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 +0x1dd
net/http.serverHandler.ServeHTTP({0x23c8f70?}, {0x23cd570, 0xc000dfa1c0}, 0xc000bf0b00)
	/usr/local/go/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc0007adef0, {0x23ce920, 0xc0002fcb70})
	/usr/local/go/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3089 +0x5ed

/source/pkg/singleflight/singleflight.go:165 (0x6cb929)
/source/pkg/singleflight/singleflight.go:200 (0x6d7f06)
/source/pkg/singleflight/singleflight.go:108 (0x6d84b8)
/source/internal/op/fs.go:260 (0x6c0548)
/source/internal/fs/link.go:19 (0xb5732f)
/source/internal/fs/fs.go:48 (0xb56250)
/source/server/handles/fsread.go:289 (0x1357afa)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x12ee667)
/source/server/middlewares/auth.go:67 (0x12ee454)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x12ee98d)
/source/server/middlewares/check.go:14 (0x12ee979)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0xb46d81)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 (0xb46d6c)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0xb45ea6)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 (0xb45e89)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0xb44f4a)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 (0xb44bd1)
/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 (0xb446fc)
/usr/local/go/src/net/http/server.go:2936 (0x56df95)
/usr/local/go/src/net/http/server.go:1995 (0x5694b1)
/usr/local/go/src/runtime/asm_amd64.s:1598 (0x27f6a0)
[0m
[GIN] 2023/07/28 - 12:37:39 | 500 |    361.0207ms |       127.0.0.1 | POST     "/api/fs/get"

```

Fix patch:
diff --git a/drivers/terabox/util.go b/drivers/terabox/util.go
index d0b10e779a1..9b1f5fd5735 100644
--- a/drivers/terabox/util.go
+++ b/drivers/terabox/util.go
@@ -3,15 +3,16 @@ package terbox
 import (
 	"encoding/base64"
 	"fmt"
-	"github.com/alist-org/alist/v3/drivers/base"
-	"github.com/alist-org/alist/v3/internal/model"
-	"github.com/alist-org/alist/v3/pkg/utils"
-	"github.com/go-resty/resty/v2"
 	"net/http"
 	"net/url"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/alist-org/alist/v3/drivers/base"
+	"github.com/alist-org/alist/v3/internal/model"
+	"github.com/alist-org/alist/v3/pkg/utils"
+	"github.com/go-resty/resty/v2"
 )
 
 func (d *Terabox) request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
@@ -139,6 +140,11 @@ func (d *Terabox) linkOfficial(file model.Obj, args model.LinkArgs) (*model.Link
 	if err != nil {
 		return nil, err
 	}
+
+	if len(resp.Dlink) == 0 {
+		return nil, fmt.Errorf("fid %s no dlink found, errno: %d", file.GetID(), resp.Errno)
+	}
+
 	res, err := base.NoRedirectClient.R().SetHeader("Cookie", d.Cookie).SetHeader("User-Agent", base.UserAgent).Get(resp.Dlink[0].Dlink)
 	if err != nil {
 		return nil, err


Test patch: