Skip to content

Commit 75636e4

Browse files
committed
fix bug
1 parent 0036e1b commit 75636e4

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

drivers/github/util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"io"
98
"strings"
109
"text/template"
1110
"time"
@@ -159,7 +158,7 @@ func signCommit(m *map[string]interface{}, entity *openpgp.Entity) (string, erro
159158
if err != nil {
160159
return "", err
161160
}
162-
if _, err = io.Copy(armorWriter, &sigBuffer); err != nil {
161+
if _, err = utils.CopyWithBuffer(armorWriter, &sigBuffer); err != nil {
163162
return "", err
164163
}
165164
_ = armorWriter.Close()

internal/archive/archives/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/alist-org/alist/v3/internal/errs"
1111
"github.com/alist-org/alist/v3/internal/model"
1212
"github.com/alist-org/alist/v3/internal/stream"
13+
"github.com/alist-org/alist/v3/pkg/utils"
1314
"github.com/mholt/archives"
1415
)
1516

@@ -73,7 +74,7 @@ func decompress(fsys fs2.FS, filePath, targetPath string, up model.UpdateProgres
7374
return err
7475
}
7576
defer f.Close()
76-
_, err = io.Copy(f, &stream.ReaderUpdatingProgress{
77+
_, err = utils.CopyWithBuffer(f, &stream.ReaderUpdatingProgress{
7778
Reader: &stream.SimpleReaderWithSize{
7879
Reader: rc,
7980
Size: stat.Size(),

internal/archive/iso9660/utils.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package iso9660
22

33
import (
4+
"os"
5+
stdpath "path"
6+
"strings"
7+
48
"github.com/alist-org/alist/v3/internal/errs"
59
"github.com/alist-org/alist/v3/internal/model"
610
"github.com/alist-org/alist/v3/internal/stream"
11+
"github.com/alist-org/alist/v3/pkg/utils"
712
"github.com/kdomanski/iso9660"
8-
"io"
9-
"os"
10-
stdpath "path"
11-
"strings"
1213
)
1314

1415
func getImage(ss *stream.SeekableStream) (*iso9660.Image, error) {
@@ -66,7 +67,7 @@ func decompress(f *iso9660.File, path string, up model.UpdateProgress) error {
6667
return err
6768
}
6869
defer file.Close()
69-
_, err = io.Copy(file, &stream.ReaderUpdatingProgress{
70+
_, err = utils.CopyWithBuffer(file, &stream.ReaderUpdatingProgress{
7071
Reader: &stream.SimpleReaderWithSize{
7172
Reader: f.Reader(),
7273
Size: f.Size(),

internal/archive/zip/utils.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ package zip
22

33
import (
44
"bytes"
5+
"io"
6+
"os"
7+
stdpath "path"
8+
"strings"
9+
510
"github.com/alist-org/alist/v3/internal/errs"
611
"github.com/alist-org/alist/v3/internal/model"
712
"github.com/alist-org/alist/v3/internal/stream"
13+
"github.com/alist-org/alist/v3/pkg/utils"
814
"github.com/saintfish/chardet"
915
"github.com/yeka/zip"
1016
"golang.org/x/text/encoding"
@@ -16,10 +22,6 @@ import (
1622
"golang.org/x/text/encoding/unicode"
1723
"golang.org/x/text/encoding/unicode/utf32"
1824
"golang.org/x/text/transform"
19-
"io"
20-
"os"
21-
stdpath "path"
22-
"strings"
2325
)
2426

2527
func toModelObj(file os.FileInfo) *model.Object {
@@ -64,7 +66,7 @@ func _decompress(file *zip.File, targetPath, password string, up model.UpdatePro
6466
return err
6567
}
6668
defer f.Close()
67-
_, err = io.Copy(f, &stream.ReaderUpdatingProgress{
69+
_, err = utils.CopyWithBuffer(f, &stream.ReaderUpdatingProgress{
6870
Reader: &stream.SimpleReaderWithSize{
6971
Reader: rc,
7072
Size: file.FileInfo().Size(),

server/handles/fsup.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package handles
22

33
import (
4-
"github.com/alist-org/alist/v3/internal/task"
5-
"github.com/alist-org/alist/v3/pkg/utils"
64
"io"
75
"net/url"
86
stdpath "path"
97
"strconv"
108
"time"
119

10+
"github.com/alist-org/alist/v3/internal/task"
11+
"github.com/alist-org/alist/v3/pkg/utils"
12+
1213
"github.com/alist-org/alist/v3/internal/fs"
1314
"github.com/alist-org/alist/v3/internal/model"
1415
"github.com/alist-org/alist/v3/internal/stream"
@@ -44,7 +45,7 @@ func FsStream(c *gin.Context) {
4445
}
4546
if !overwrite {
4647
if res, _ := fs.Get(c, path, &fs.GetArgs{NoLog: true}); res != nil {
47-
_, _ = io.Copy(io.Discard, c.Request.Body)
48+
_, _ = utils.CopyWithBuffer(io.Discard, c.Request.Body)
4849
common.ErrorStrResp(c, "file exists", 403)
4950
return
5051
}
@@ -89,6 +90,9 @@ func FsStream(c *gin.Context) {
8990
return
9091
}
9192
if t == nil {
93+
if n, _ := c.Request.Body.Read([]byte{0}); n == 1 {
94+
_, _ = utils.CopyWithBuffer(io.Discard, c.Request.Body)
95+
}
9296
common.SuccessResp(c)
9397
return
9498
}
@@ -114,7 +118,7 @@ func FsForm(c *gin.Context) {
114118
}
115119
if !overwrite {
116120
if res, _ := fs.Get(c, path, &fs.GetArgs{NoLog: true}); res != nil {
117-
_, _ = io.Copy(io.Discard, c.Request.Body)
121+
_, _ = utils.CopyWithBuffer(io.Discard, c.Request.Body)
118122
common.ErrorStrResp(c, "file exists", 403)
119123
return
120124
}

0 commit comments

Comments
 (0)