8000 feat(archive): archive manage (#7817) · anwen-anyi/alist@bb40e2e · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit bb40e2e

Browse files
authored
feat(archive): archive manage (AlistGo#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
1 parent ab22cf8 commit bb40e2e

36 files changed

+2849
-122
lines changed

cmd/kill.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package cmd
2+
3+
import (
4+
log "github.com/sirupsen/logrus"
5+
"github.com/spf13/cobra"
6+
"os"
7+
)
8+
9+
// KillCmd represents the kill command
10+
var KillCmd = &cobra.Command{
11+
Use: "kill",
12+
Short: "Force kill alist server process by daemon/pid file",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
kill()
15+
},
16+
}
17+
18+
func kill() {
19+
initDaemon()
20+
if pid == -1 {
21+
log.Info("Seems not have been started. Try use `alist start` to start server.")
22+
return
23+
}
24+
process, err := os.FindProcess(pid)
25+
if err != nil {
26+
log.Errorf("failed to find process by pid: %d, reason: %v", pid, process)
27+
return
28+
}
29+
err = process.Kill()
30+
if err != nil {
31+
log.Errorf("failed to kill process %d: %v", pid, err)
32+
} else {
33+
log.Info("killed process: ", pid)
34+
}
35+
err = os.Remove(pidFile)
36+
if err != nil {
37+
log.Errorf("failed to remove pid file")
38+
}
39+
pid = -1
40+
}
41+
42+
func init() {
43+
RootCmd.AddCommand(KillCmd)
44+
45+
// Here you will define your flags and configuration settings.
46+
47+
// Cobra supports Persistent Flags which will work for this command
48+
// and all subcommands, e.g.:
49+
// stopCmd.PersistentFlags().String("foo", "", "A help for foo")
50+
51+
// Cobra supports local flags which will only run when this command
52+
// is called directly, e.g.:
53+
// stopCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
54+
}

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/alist-org/alist/v3/cmd/flags"
88
_ "github.com/alist-org/alist/v3/drivers"
9+
_ "github.com/alist-org/alist/v3/internal/archive"
910
_ "github.com/alist-org/alist/v3/internal/offline_download"
1011
"github.com/spf13/cobra"
1112
)

cmd/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
ftpserver "github.com/KirCute/ftpserverlib-pasvportmap"
88
"github.com/KirCute/sftpd-alist"
9+
"github.com/alist-org/alist/v3/internal/fs"
910
"net"
1011
"net/http"
1112
"os"
@@ -159,6 +160,7 @@ the address is defined in config file`,
159160
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
160161
<-quit
161162
utils.Log.Println("Shutdown server...")
163+
fs.ArchiveContentUploadTaskManager.RemoveAll()
162164
Release()
163165
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
164166
defer cancel()

cmd/stop.go renamed to cmd/stop_default.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3-
*/
1+
//go:build !windows
2+
43
package cmd
54

65
import (
76
"os"
7+
"syscall"
88

99
log "github.com/sirupsen/logrus"
1010
"github.com/spf13/cobra"
@@ -30,11 +30,11 @@ func stop() {
3030
log.Errorf("failed to find process by pid: %d, reason: %v", pid, process)
3131
return
3232
}
33-
err = process.Kill()
33+
err = process.Signal(syscall.SIGTERM)
3434
if err != nil {
35-
log.Errorf("failed to kill process %d: %v", pid, err)
35+
log.Errorf("failed to terminate process %d: %v", pid, err)
3636
} else {
37-
log.Info("killed process: ", pid)
37+
log.Info("terminated process: ", pid)
3838
}
3939
err = os.Remove(pidFile)
4040
if err != nil {

cmd/stop_windows.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//go:build windows
2+
3+
package cmd
4+
5+
import (
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// StopCmd represents the stop command
10+
var StopCmd = &cobra.Command{
11+
Use: "stop",
12+
Short: "Same as the kill command",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
stop()
15+
},
16+
}
17+
18+
func stop() {
19+
kill()
20+
}
21+
22+
func init() {
23+
RootCmd.AddCommand(StopCmd)
24+
25+
// Here you will define your flags and configuration settings.
26+
27+
// Cobra supports Persistent Flags which will work for this command
28+
// and all subcommands, e.g.:
29+
// stopCmd.PersistentFlags().String("foo", "", "A help for foo")
30+
31+
// Cobra supports local flags which will only run when this command
32+
// is called directly, e.g.:
33+
// stopCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
34+
}

go.mod

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/alist-org/alist/v3
22

3-
go 1.22.4
3+
go 1.23
4+
5+
toolchain go1.23.1
46

57
require (
68
github.com/KirCute/ftpserverlib-pasvportmap v1.25.0
@@ -40,17 +42,20 @@ require (
4042
github.com/ipfs/go-ipfs-api v0.7.0
4143
github.com/jlaffaye/ftp v0.2.0
4244
github.com/json-iterator/go v1.1.12
45+
github.com/kdomanski/iso9660 v0.4.0
4346
github.com/larksuite/oapi-sdk-go/v3 v3.3.1
4447
github.com/maruel/natural v1.1.1
4548
github.com/meilisearch/meilisearch-go v0.27.2
49+
github.com/mholt/archives v0.1.0
4650
github.com/minio/sio v0.4.0
4751
github.com/natefinch/lumberjack v2.0.0+incompatible
4852
github.com/ncw/swift/v2 v2.0.3
49-
github.com/orzogc/fake115uploader v0.3.3-0.20230715111618-58f9eb76f831
53+
github.com/orzogc/fake115uploader v0.6.2
5054
github.com/pkg/errors v0.9.1
5155
github.com/pkg/sftp v1.13.6
5256
github.com/pquerna/otp v1.4.0
5357
github.com/rclone/rclone v1.67.0
58+
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d
5459
github.com/sirupsen/logrus v1.9.3
5560
github.com/spf13/afero v1.11.0
5661
github.com/spf13/cobra v1.8.1
@@ -61,6 +66,7 @@ require (
6166
github.com/winfsp/cgofuse v1.5.1-0.20230130140708-f87f5db493b5
6267
github.com/xhofe/tache v0.1.3
6368
github.com/xhofe/wopan-sdk-go v0.1.3
69+
github.com/yeka/zip v0.0.0-20231116150916-03d6312748a9
6470
github.com/zzzhr1990/go-common-entity v0.0.0-20221216044934-fd1c571e3a22
6571
golang.org/x/crypto v0.31.0
6672
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
@@ -77,30 +83,41 @@ require (
7783
)
7884

7985
require (
80-
github.com/BurntSushi/toml v0.3.1 // indirect
86+
github.com/STARRY-S/zip v0.2.1 // indirect
8187
github.com/blevesearch/go-faiss v1.0.20 // indirect
8288
github.com/blevesearch/zapx/v16 v16.1.5 // indirect
89+
github.com/bodgit/plumbing v1.3.0 // indirect
90+
github.com/bodgit/sevenzip v1.6.0 // indirect
91+
github.com/bodgit/windows v1.0.1 // indirect
8392
github.com/bytedance/sonic/loader v0.1.1 // indirect
8493
github.com/charmbracelet/x/ansi v0.2.3 // indirect
8594
github.com/charmbracelet/x/term v0.2.0 // indirect
8695
github.com/cloudwego/base64x v0.1.4 // indirect
8796
github.com/cloudwego/iasm v0.2.0 // indirect
97+
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
8898
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
8999
github.com/fclairamb/go-log v0.5.0 // indirect
90100
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
101+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
91102
github.com/hekmon/cunits/v2 v2.1.0 // indirect
92103
github.com/ipfs/boxo v0.12.0 // indirect
93104
github.com/jackc/puddle/v2 v2.2.1 // indirect
105+
github.com/klauspost/pgzip v1.2.6 // indirect
106+
github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78 // indirect
107+
github.com/sorairolake/lzip-go v0.3.5 // indirect
94108
github.com/taruti/bytepool v0.0.0-20160310082835-5e3a9ea56543 // indirect
109+
github.com/therootcompany/xz v1.0.1 // indirect
110+
github.com/ulikunitz/xz v0.5.12 // indirect
111+
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
95112
)
96113

97114
require (
98115
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd // indirect
99116
github.com/RoaringBitmap/roaring v1.9.3 // indirect
100117
github.com/abbot/go-http-auth v0.4.0 // indirect
101118
github.com/aead/ecdh v0.2.0 // indirect
102-
github.com/andreburgaud/crypt2go v1.2.0 // indirect
103-
github.com/andybalholm/brotli v1.0.4 // indirect
119+
github.com/andreburgaud/crypt2go v1.8.0 // indirect
120+
github.com/andybalholm/brotli v1.1.1 // indirect
104121
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
105122
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
106123
github.com/benbjohnson/clock v1.3.0 // indirect
@@ -161,7 +178,7 @@ require (
161178
github.com/jmespath/go-jmespath v0.4.0 // indirect
162179
github.com/josharian/intern v1.0.0 // indirect
163180
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
164-
github.com/klauspost/compress v1.17.8 // indirect
181+
github.com/klauspost/compress v1.17.11 // indirect
165182
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
166183
github.com/kr/fs v0.1.0 // indirect
167184
github.com/leodido/go-urn v1.4.0 // indirect
@@ -196,7 +213,7 @@ require (
196213
github.com/multiformats/go-varint v0.0.7 // indirect
197214
github.com/otiai10/copy v1.14.0
198215
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
199-
github.com/pierrec/lz4/v4 v4.1.18 // indirect
216+
github.com/pierrec/lz4/v4 v4.1.21 // indirect
200217
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
201218
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
202219
github.com/pquerna/cachecontrol v0.1.0 // indirect
@@ -228,7 +245,7 @@ require (
228245
golang.org/x/sync v0.10.0 // indirect
229246
golang.org/x/sys v0.28.0 // indirect
230247
golang.org/x/term v0.27.0 // indirect
231-
golang.org/x/text v0.21.0 // indirect
248+
golang.org/x/text v0.21.0
232249
golang.org/x/tools v0.24.0 // indirect
233250
google.golang.org/api v0.169.0 // indirect
234251
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect

0 commit comments

Comments
 (0)
0