@@ -12,7 +12,7 @@ import (
12
12
packages_model "code.gitea.io/gitea/models/packages"
13
13
packages_module "code.gitea.io/gitea/modules/packages"
14
14
"code.gitea.io/gitea/modules/setting"
15
- "code.gitea.io/gitea/modules/util "
15
+ "code.gitea.io/gitea/modules/tempdir "
16
16
)
17
17
18
18
var (
@@ -30,8 +30,12 @@ type BlobUploader struct {
30
30
reading bool
31
31
}
32
32
33
- func buildFilePath (id string ) string {
34
- return util .FilePathJoinAbs (setting .Packages .ChunkedUploadPath , id )
33
+ func uploadPathTempDir () * tempdir.TempDir {
34
+ return setting .AppDataTempDir ("package-upload" )
35
+ }
36
+
37
+ func buildFilePath (uploadPath * tempdir.TempDir , id string ) string {
38
+ return uploadPath .JoinPath (id )
35
39
}
36
40
37
41
// NewBlobUploader creates a new blob uploader for the given id
@@ -48,7 +52,12 @@ func NewBlobUploader(ctx context.Context, id string) (*BlobUploader, error) {
48
52
}
49
53
}
50
54
51
- f , err := os .OpenFile (buildFilePath (model .ID ), os .O_RDWR | os .O_CREATE , 0o666 )
55
+ uploadPath := uploadPathTempDir ()
56
+ _ , err = uploadPath .MkdirAllSub ("" )
57
+ if err != nil {
58
+ return nil , err
59
+ }
60
+ f , err := os .OpenFile (buildFilePath (uploadPath , model .ID ), os .O_RDWR | os .O_CREATE , 0o666 )
52
61
if err != nil {
53
62
return nil , err
54
63
}
@@ -118,13 +127,13 @@ func (u *BlobUploader) Read(p []byte) (int, error) {
118
127
return u .file .Read (p )
119
128
}
120
129
121
- // Remove deletes the data and the model of a blob upload
130
+ // RemoveBlobUploadByID Remove deletes the data and the model of a blob upload
122
131
func RemoveBlobUploadByID (ctx context.Context , id string ) error {
123
132
if err := packages_model .DeleteBlobUploadByID (ctx , id ); err != nil {
124
133
return err
125
134
}
126
135
127
- err := os .Remove (buildFilePath (id ))
136
+ err := os .Remove (buildFilePath (uploadPathTempDir (), id ))
128
137
if err != nil && ! os .IsNotExist (err ) {
129
138
return err
130
139
}
0 commit comments