aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo/upload.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo/upload.go')
-rw-r--r--models/repo/upload.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/models/repo/upload.go b/models/repo/upload.go
index cae11df96a..f7d4749842 100644
--- a/models/repo/upload.go
+++ b/models/repo/upload.go
@@ -51,14 +51,10 @@ func init() {
db.RegisterModel(new(Upload))
}
-// UploadLocalPath returns where uploads is stored in local file system based on given UUID.
-func UploadLocalPath(uuid string) string {
- return filepath.Join(setting.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
-}
-
-// LocalPath returns where uploads are temporarily stored in local file system.
+// LocalPath returns where uploads are temporarily stored in local file system based on given UUID.
func (upload *Upload) LocalPath() string {
- return UploadLocalPath(upload.UUID)
+ uuid := upload.UUID
+ return setting.AppDataTempDir("repo-uploads").JoinPath(uuid[0:1], uuid[1:2], uuid)
}
// NewUpload creates a new upload object.
@@ -121,24 +117,14 @@ func DeleteUploads(ctx context.Context, uploads ...*Upload) (err error) {
return nil
}
- ctx, committer, err := db.TxContext(ctx)
- if err != nil {
- return err
- }
- defer committer.Close()
-
ids := make([]int64, len(uploads))
- for i := 0; i < len(uploads); i++ {
+ for i := range uploads {
ids[i] = uploads[i].ID
}
if err = db.DeleteByIDs[Upload](ctx, ids...); err != nil {
return fmt.Errorf("delete uploads: %w", err)
}
- if err = committer.Commit(); err != nil {
- return err
- }
-
for _, upload := range uploads {
localPath := upload.LocalPath()
isFile, err := util.IsFile(localPath)