Repository: AlistGo/alist (language: go)

Issue:
Quark upload some file failed.
### 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 版本

v 3.8.0

### Driver used / 使用的存储驱动

Quark

### Describe the bug / 问题描述

Some files upload failed due to quark driver panic.

### Reproduction / 复现链接

See log.

### Logs / 日志

[Recovery] 2023/01/17 - 08:44:09 panic recovered:
runtime error: integer divide by zero
/usr/lib/go/src/runtime/panic.go:239 (0x43eac4)
/app/drivers/quark/driver.go:206 (0x13070ee)
/app/internal/op/fs.go:503 (0x87623a)
/app/internal/fs/put.go:54 (0xb724c4)
/app/internal/fs/fs.go:84 (0xb70444)
/app/server/webdav/webdav.go:325 (0x1426d4f)
/app/server/webdav/webdav.go:62 (0x142440f)
/app/server/webdav.go:44 (0x1431384)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/context.go:173 (0x1431a78)
/app/server/webdav.go:93 (0x1431973)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/context.go:173 (0x13b4f4c)
/app/server/middlewares/check.go:14 (0x13b4cd7)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/context.go:173 (0xf70a61)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/recovery.go:101 (0xf70a4c)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/context.go:173 (0xf6fb66)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/logger.go:240 (0xf6fb49)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/context.go:173 (0xf6ec30)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/gin.go:616 (0xf6e898)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.8.2/gin.go:572 (0xf6e3dc)
/usr/lib/go/src/net/http/server.go:2947 (0x73a0cb)
/usr/lib/go/src/net/http/server.go:1991 (0x7352e6)
/usr/lib/go/src/runtime/asm_amd64.s:1594 (0x474ea0)


Discussion / hints:

Fix patch:
diff --git a/drivers/quark/driver.go b/drivers/quark/driver.go
index 599ed4f5afb..9b67ed44b1e 100644
--- a/drivers/quark/driver.go
+++ b/drivers/quark/driver.go
@@ -175,9 +175,9 @@ func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStre
 	var bytes []byte
 	md5s := make([]string, 0)
 	defaultBytes := make([]byte, partSize)
-	left := stream.GetSize()
+	total := stream.GetSize()
+	left := total
 	partNumber := 1
-	sizeDivide100 := stream.GetSize() / 100
 	for left > 0 {
 		if utils.IsCanceled(ctx) {
 			return ctx.Err()
@@ -191,7 +191,7 @@ func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStre
 		if err != nil {
 			return err
 		}
-		left -= int64(partSize)
+		left -= len(bytes)
 		log.Debugf("left: %d", left)
 		m, err := d.upPart(ctx, pre, stream.GetMimetype(), partNumber, bytes)
 		//m, err := driver.UpPart(pre, file.GetMIMEType(), partNumber, bytes, account, md5Str, sha1Str)
@@ -203,7 +203,7 @@ func (d *Quark) Put(ctx context.Context, dstDir model.Obj, stream model.FileStre
 		}
 		md5s = append(md5s, m)
 		partNumber++
-		up(100 - int(left/sizeDivide100))
+		up(100 * (total - left) / total)
 	}
 	err = d.upCommit(pre, md5s)
 	if err != nil {


Test patch: