@@ -8,8 +8,10 @@ import (
88 "time"
99
1010 "github.com/OpenListTeam/OpenList/v4/internal/conf"
11+ "github.com/OpenListTeam/OpenList/v4/internal/errs"
1112 "github.com/OpenListTeam/OpenList/v4/internal/fs"
1213 "github.com/OpenListTeam/OpenList/v4/internal/model"
14+ "github.com/OpenListTeam/OpenList/v4/internal/setting"
1315 "github.com/OpenListTeam/OpenList/v4/internal/stream"
1416 "github.com/OpenListTeam/OpenList/v4/internal/task"
1517 "github.com/OpenListTeam/OpenList/v4/pkg/utils"
@@ -28,6 +30,14 @@ func getLastModified(c *gin.Context) time.Time {
2830 return lastModified
2931}
3032
33+ // shouldIgnoreSystemFile checks if the filename should be ignored based on settings
34+ func shouldIgnoreSystemFile (filename string ) bool {
35+ if setting .GetBool (conf .IgnoreSystemFiles ) {
36+ return utils .IsSystemFile (filename )
37+ }
38+ return false
39+ }
40+
3141func FsStream (c * gin.Context ) {
3242 defer func () {
3343 if n , _ := io .ReadFull (c .Request .Body , []byte {0 }); n == 1 {
@@ -56,6 +66,11 @@ func FsStream(c *gin.Context) {
5666 }
5767 }
5868 dir , name := stdpath .Split (path )
69+ // Check if system file should be ignored
70+ if shouldIgnoreSystemFile (name ) {
71+ common .ErrorStrResp (c , errs .IgnoredSystemFile .Error (), 403 )
72+ return
73+ }
5974 // 如果请求头 Content-Length 和 X-File-Size 都没有,则 size=-1,表示未知大小的流式上传
6075 size := c .Request .ContentLength
6176 if size < 0 {
@@ -160,6 +175,11 @@ func FsForm(c *gin.Context) {
160175 }
161176 defer f .Close ()
162177 dir , name := stdpath .Split (path )
178+ // Check if system file should be ignored
179+ if shouldIgnoreSystemFile (name ) {
180+ common .ErrorStrResp (c , errs .IgnoredSystemFile .Error (), 403 )
181+ return
182+ }
163183 h := make (map [* utils.HashType ]string )
164184 if md5 := c .GetHeader ("X-File-Md5" ); md5 != "" {
165185 h [utils .MD5 ] = md5
0 commit comments