feat(archive): archive manage (#7817)

* feat(archive): archive management

* fix(ftp-server): remove duplicate ReadAtSeeker realization

* fix(archive): bad seeking of SeekableStream

* fix(archive): split internal and driver extraction api

* feat(archive): patch

* fix(shutdown): clear decompress upload tasks

* chore

* feat(archive): support .iso format

* chore
This commit is contained in:
KirCute_ECT
2025-01-18 23:28:12 +08:00
committed by GitHub
parent ab22cf8233
commit bb40e2e2cd
36 changed files with 2854 additions and 127 deletions

49
internal/model/archive.go Normal file
View File

@ -0,0 +1,49 @@
package model
type ObjTree interface {
Obj
GetChildren() []ObjTree
}
type ObjectTree struct {
Object
Children []ObjTree
}
func (t *ObjectTree) GetChildren() []ObjTree {
return t.Children
}
type ArchiveMeta interface {
GetComment() string
// IsEncrypted means if the content of the archive requires a password to access
// GetArchiveMeta should return errs.WrongArchivePassword if the meta-info is also encrypted,
// and the provided password is empty.
IsEncrypted() bool
// GetTree directly returns the full folder structure
// returns nil if the folder structure should be acquired by calling driver.ArchiveReader.ListArchive
GetTree() []ObjTree
}
type ArchiveMetaInfo struct {
Comment string
Encrypted bool
Tree []ObjTree
}
func (m *ArchiveMetaInfo) GetComment() string {
return m.Comment
}
func (m *ArchiveMetaInfo) IsEncrypted() bool {
return m.Encrypted
}
func (m *ArchiveMetaInfo) GetTree() []ObjTree {
return m.Tree
}
type ArchiveMetaProvider struct {
ArchiveMeta
DriverProviding bool
}

View File

@ -48,6 +48,33 @@ type FsOtherArgs struct {
Method string `json:"method" form:"method"`
Data interface{} `json:"data" form:"data"`
}
type ArchiveArgs struct {
Password string
LinkArgs
}
type ArchiveInnerArgs struct {
ArchiveArgs
InnerPath string
}
type ArchiveMetaArgs struct {
ArchiveArgs
Refresh bool
}
type ArchiveListArgs struct {
ArchiveInnerArgs
Refresh bool
}
type ArchiveDecompressArgs struct {
ArchiveInnerArgs
CacheFull bool
PutIntoNewDir bool
}
type RangeReadCloserIF interface {
RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error)
utils.ClosersIF

View File

@ -48,8 +48,11 @@ type FileStreamer interface {
RangeRead(http_range.Range) (io.Reader, error)
//for a non-seekable Stream, if Read is called, this function won't work
CacheFullInTempFile() (File, error)
CacheFullInTempFileAndUpdateProgress(up UpdateProgress) (File, error)
}
type UpdateProgress func(percentage float64)
type URL interface {
URL() string
}

View File

@ -44,6 +44,8 @@ type User struct {
// 9: webdav write
// 10: ftp/sftp login and read
// 11: ftp/sftp write
// 12: can read archives
// 13: can decompress archives
Permission int32 `json:"permission"`
OtpSecret string `json:"-"`
SsoID string `json:"sso_id"` // unique by sso platform
@ -127,6 +129,14 @@ func (u *User) CanFTPManage() bool {
return (u.Permission>>11)&1 == 1
}
func (u *User) CanReadArchives() bool {
return (u.Permission>>12)&1 == 1
}
func (u *User) CanDecompress() bool {
return (u.Permission>>13)&1 == 1
}
func (u *User) JoinPath(reqPath string) (string, error) {
return utils.JoinBasePath(u.BasePath, reqPath)
}