summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-09-29 11:05:13 +0200
committerGitHub <noreply@github.com>2020-09-29 11:05:13 +0200
commit3878e985b66cc6d4cb4d2b0e7406d5cf91af6191 (patch)
tree31229c29c2b57041d1941ec28b043165cbe4642d /models
parentCompletely quote AppPath and CustomConf paths (#12955) (diff)
downloadforgejo-3878e985b66cc6d4cb4d2b0e7406d5cf91af6191.tar.xz
forgejo-3878e985b66cc6d4cb4d2b0e7406d5cf91af6191.zip
Add default storage configurations (#12813)
Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models')
-rw-r--r--models/admin.go4
-rw-r--r--models/repo.go3
-rw-r--r--models/unit_tests.go6
3 files changed, 9 insertions, 4 deletions
diff --git a/models/admin.go b/models/admin.go
index 9ed9c44ebb..903e35b0c9 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -70,6 +70,10 @@ func RemoveAllWithNotice(title, path string) {
// RemoveStorageWithNotice removes a file from the storage and
// creates a system notice when error occurs.
func RemoveStorageWithNotice(bucket storage.ObjectStorage, title, path string) {
+ removeStorageWithNotice(x, bucket, title, path)
+}
+
+func removeStorageWithNotice(e Engine, bucket storage.ObjectStorage, title, path string) {
if err := bucket.Delete(path); err != nil {
desc := fmt.Sprintf("%s [%s]: %v", title, path, err)
log.Warn(title+" [%s]: %v", path, err)
diff --git a/models/repo.go b/models/repo.go
index 46f91fc7df..a743f65737 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1748,8 +1748,7 @@ func DeleteRepository(doer *User, uid, repoID int64) error {
continue
}
- oidPath := filepath.Join(setting.LFS.ContentPath, v.Oid[0:2], v.Oid[2:4], v.Oid[4:len(v.Oid)])
- removeAllWithNotice(sess, "Delete orphaned LFS file", oidPath)
+ removeStorageWithNotice(sess, storage.LFS, "Delete orphaned LFS file", v.RelativePath())
}
if _, err := sess.Delete(&LFSMetaObject{RepositoryID: repoID}); err != nil {
diff --git a/models/unit_tests.go b/models/unit_tests.go
index e977f706f8..c4f9091a4b 100644
--- a/models/unit_tests.go
+++ b/models/unit_tests.go
@@ -67,9 +67,11 @@ func MainTest(m *testing.M, pathToGiteaRoot string) {
if err != nil {
fatalTestError("url.Parse: %v\n", err)
}
+ setting.Attachment.Storage.Type = setting.LocalStorageType
+ setting.Attachment.Storage.Path = filepath.Join(setting.AppDataPath, "attachments")
- setting.Attachment.Path = filepath.Join(setting.AppDataPath, "attachments")
- setting.LFS.ContentPath = filepath.Join(setting.AppDataPath, "lfs")
+ setting.LFS.Storage.Type = setting.LocalStorageType
+ setting.LFS.Storage.Path = filepath.Join(setting.AppDataPath, "lfs")
if err = storage.Init(); err != nil {
fatalTestError("storage.Init: %v\n", err)
}