fix: temp file not close and incorrect WebPutAsTask

This commit is contained in:
Andy Hsu 2023-08-28 18:18:02 +08:00
parent 6c4736fc8f
commit ce10c9f120
2 changed files with 6 additions and 3 deletions

View File

@ -5,12 +5,13 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io"
"os"
"github.com/alist-org/alist/v3/internal/errs" "github.com/alist-org/alist/v3/internal/errs"
"github.com/alist-org/alist/v3/internal/model" "github.com/alist-org/alist/v3/internal/model"
"github.com/alist-org/alist/v3/pkg/http_range" "github.com/alist-org/alist/v3/pkg/http_range"
"github.com/alist-org/alist/v3/pkg/utils" "github.com/alist-org/alist/v3/pkg/utils"
"io"
"os"
) )
type FileStream struct { type FileStream struct {
@ -66,6 +67,7 @@ func (f *FileStream) CacheFullInTempFile() (model.File, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
f.Add(tmpF)
f.tmpFile = tmpF f.tmpFile = tmpF
f.Reader = tmpF f.Reader = tmpF
return f.tmpFile, nil return f.tmpFile, nil
@ -220,6 +222,7 @@ func (ss *SeekableStream) CacheFullInTempFile() (model.File, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
ss.Add(tmpF)
ss.tmpFile = tmpF ss.tmpFile = tmpF
ss.Reader = tmpF ss.Reader = tmpF
return ss.tmpFile, nil return ss.tmpFile, nil

View File

@ -111,7 +111,7 @@ func FsForm(c *gin.Context) {
}, },
Reader: f, Reader: f,
Mimetype: file.Header.Get("Content-Type"), Mimetype: file.Header.Get("Content-Type"),
WebPutAsTask: false, WebPutAsTask: asTask,
} }
ss, err := stream.NewSeekableStream(s, nil) ss, err := stream.NewSeekableStream(s, nil)
if err != nil { if err != nil {