Parcourir la source

[models/admin] Minimising file diffs with upstream

Moved GIN code from models/admin.go to models/admin_gin.go
Achilleas Koutsou il y a 6 ans
Parent
commit
03c34f5ad4
2 fichiers modifiés avec 21 ajouts et 11 suppressions
  1. 1 11
      models/admin.go
  2. 20 0
      models/admin_gin.go

+ 1 - 11
models/admin.go

@@ -14,7 +14,6 @@ import (
 	"github.com/go-xorm/xorm"
 	log "gopkg.in/clog.v1"
 
-	gannex "github.com/G-Node/go-annex"
 	"github.com/G-Node/gogs/pkg/tool"
 )
 
@@ -72,16 +71,7 @@ func CreateRepositoryNotice(desc string) error {
 // RemoveAllWithNotice removes all directories in given path and
 // creates a system notice when error occurs.
 func RemoveAllWithNotice(title, path string) {
-	if msg, err := gannex.AUInit(path); err != nil {
-		if strings.Contains(msg, "If you don't care about preserving the data") {
-			log.Trace("Annex uninit Repo: %s", msg)
-		} else {
-			log.Error(1, "Could not annex uninit repo. Error: %s,%s", err, msg)
-		}
-	} else {
-		log.Trace("Annex uninit Repo:%s", msg)
-	}
-
+	annexUninit(path) // uninit annex to allow deleting
 	if err := os.RemoveAll(path); err != nil {
 		desc := fmt.Sprintf("%s [%s]: %v", title, path, err)
 		log.Warn(desc)

+ 20 - 0
models/admin_gin.go

@@ -0,0 +1,20 @@
+package models
+
+import (
+	"strings"
+
+	gannex "github.com/G-Node/go-annex"
+	log "gopkg.in/clog.v1"
+)
+
+func annexUninit(path string) {
+	if msg, err := gannex.AUInit(path); err != nil {
+		if strings.Contains(msg, "If you don't care about preserving the data") {
+			log.Trace("Annex uninit Repo: %s", msg)
+		} else {
+			log.Error(1, "Could not annex uninit repo. Error: %s,%s", err, msg)
+		}
+	} else {
+		log.Trace("Annex uninit Repo:%s", msg)
+	}
+}