-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(upload): add chunked upload support for form mode. form模式下分片传输。 #1928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| package bootstrap | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/OpenListTeam/OpenList/v4/internal/conf" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/db" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/fs" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/offline_download/tool" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/op" | ||
| "github.com/OpenListTeam/OpenList/v4/internal/setting" | ||
| "github.com/OpenListTeam/OpenList/v4/pkg/cron" | ||
| "github.com/OpenListTeam/tache" | ||
| ) | ||
|
|
||
|
|
@@ -49,4 +52,11 @@ func InitTaskManager() { | |
| op.RegisterSettingChangingCallback(func() { | ||
| fs.ArchiveContentUploadTaskManager.SetWorkersNumActive(taskFilterNegative(setting.GetInt(conf.TaskDecompressUploadThreadsNum, conf.Conf.Tasks.DecompressUpload.Workers))) | ||
| }) | ||
|
|
||
| // Start background task to clean stale chunks every 10 minutes | ||
| go func() { | ||
| c := cron.NewCron(10 * time.Minute) | ||
| c.Do(CleanStaleChunks) | ||
| }() | ||
|
Comment on lines
+56
to
+60
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 清理无用分片跟任务系统无关,应该将其放在init函数或 |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,9 +77,6 @@ const ( | |
| // 115 | ||
| Pan115TempDir = "115_temp_dir" | ||
|
|
||
| // 123 | ||
| Pan123TempDir = "123_temp_dir" | ||
|
|
||
| // 115_open | ||
| Pan115OpenTempDir = "115_open_temp_dir" | ||
|
|
||
|
|
@@ -139,6 +136,7 @@ const ( | |
| // 123 open offline download | ||
| Pan123OpenOfflineDownloadCallbackUrl = "123_open_callback_url" | ||
| Pan123OpenTempDir = "123_open_temp_dir" | ||
| Pan123TempDir = "123_temp_dir" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 补的位置不对, // 123 |
||
|
|
||
| // ftp | ||
| FTPPublicHost = "ftp_public_host" | ||
|
|
@@ -161,6 +159,16 @@ const ( | |
| StreamMaxClientUploadSpeed = "max_client_upload_speed" | ||
| StreamMaxServerDownloadSpeed = "max_server_download_speed" | ||
| StreamMaxServerUploadSpeed = "max_server_upload_speed" | ||
|
|
||
| // HTTP Server Timeouts (传输超时配置) | ||
| HTTPServerReadTimeout = "http_server_read_timeout" // 读取请求超时(秒),0表示无限制 | ||
| HTTPServerWriteTimeout = "http_server_write_timeout" // 写入响应超时(秒),0表示无限制 | ||
| HTTPServerIdleTimeout = "http_server_idle_timeout" // 空闲连接超时(秒) | ||
| HTTPServerReadHeaderTimeout = "http_server_read_header_timeout" // 读取Header超时(秒) | ||
| HTTPServerMaxHeaderBytes = "http_server_max_header_bytes" // Header最大字节数 | ||
|
|
||
| // Chunked Upload (分片上传配置) | ||
| ChunkedUploadChunkSize = "chunked_upload_chunk_size" // 分片大小(MB),超过此大小的文件将自动分片上传 | ||
| ) | ||
|
|
||
| const ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,13 @@ import ( | |
| "encoding/json" | ||
| "errors" | ||
| "hash" | ||
| "hash/crc32" | ||
| "hash/crc64" | ||
| "io" | ||
| "iter" | ||
|
|
||
| "github.com/OpenListTeam/OpenList/v4/internal/errs" | ||
| "github.com/cespare/xxhash/v2" | ||
| log "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
|
|
@@ -90,6 +93,15 @@ var ( | |
|
|
||
| // SHA256 indicates SHA-256 support | ||
| SHA256 = RegisterHash("sha256", "SHA-256", 64, sha256.New) | ||
|
|
||
| // CRC32 indicates CRC-32 support (IEEE polynomial) | ||
| CRC32 = RegisterHash("crc32", "CRC-32", 8, func() hash.Hash { return crc32.NewIEEE() }) | ||
|
|
||
| // CRC64 indicates CRC-64 support (ECMA polynomial) | ||
| CRC64 = RegisterHash("crc64", "CRC-64", 16, func() hash.Hash { return crc64.New(crc64.MakeTable(crc64.ECMA)) }) | ||
|
|
||
| // XXH64 indicates xxHash64 support | ||
| XXH64 = RegisterHash("xxh64", "XXH64", 16, func() hash.Hash { return xxhash.New() }) | ||
|
Comment on lines
+97
to
+104
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不是项目里所有用到的哈希算法都要在这个位置注册,这个位置注册的是网盘可能返回的用于秒传的哈希值。 |
||
| ) | ||
|
|
||
| // HashData get hash of one hashType | ||
|
|
@@ -242,3 +254,4 @@ func (hi HashInfo) All() iter.Seq2[*HashType, string] { | |
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我没有找到这些配置项是在哪用到的,如果是前端用到的,应该将
Flag全部设为model.PUBLIC,否则前端看不到这个配置项的值。