@@ -12,7 +12,7 @@ import (
1212	packages_model "code.gitea.io/gitea/models/packages" 
1313	packages_module "code.gitea.io/gitea/modules/packages" 
1414	"code.gitea.io/gitea/modules/setting" 
15- 	"code.gitea.io/gitea/modules/util " 
15+ 	"code.gitea.io/gitea/modules/tempdir " 
1616)
1717
1818var  (
@@ -30,8 +30,12 @@ type BlobUploader struct {
3030	reading  bool 
3131}
3232
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 )
3539}
3640
3741// NewBlobUploader creates a new blob uploader for the given id 
@@ -48,7 +52,12 @@ func NewBlobUploader(ctx context.Context, id string) (*BlobUploader, error) {
4852		}
4953	}
5054
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 )
5261	if  err  !=  nil  {
5362		return  nil , err 
5463	}
@@ -118,13 +127,13 @@ func (u *BlobUploader) Read(p []byte) (int, error) {
118127	return  u .file .Read (p )
119128}
120129
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 
122131func  RemoveBlobUploadByID (ctx  context.Context , id  string ) error  {
123132	if  err  :=  packages_model .DeleteBlobUploadByID (ctx , id ); err  !=  nil  {
124133		return  err 
125134	}
126135
127- 	err  :=  os .Remove (buildFilePath (id ))
136+ 	err  :=  os .Remove (buildFilePath (uploadPathTempDir (),  id ))
128137	if  err  !=  nil  &&  ! os .IsNotExist (err ) {
129138		return  err 
130139	}
0 commit comments