فهرست منبع

Fixed FSH toggle bug

aroz 1 سال پیش
والد
کامیت
d8ae16eb78
2فایلهای تغییر یافته به همراه4 افزوده شده و 72 حذف شده
  1. 3 0
      mod/disk/raid/raiddetails.go
  2. 1 72
      storage.pool.go

+ 3 - 0
mod/disk/raid/raiddetails.go

@@ -26,6 +26,7 @@ type RAIDInfo struct {
 	FailedDevices  int
 	SpareDevices   int
 	Consistency    string
+	RebuildStatus  string
 	Name           string
 	UUID           string
 	Events         int
@@ -102,6 +103,8 @@ func parseRAIDInfo(output string) *RAIDInfo {
 				raidInfo.SpareDevices, _ = strconv.Atoi(fields[3])
 			case "Consistency":
 				raidInfo.Consistency = strings.Join(fields[3:], " ")
+			case "Rebuild":
+				raidInfo.RebuildStatus = strings.Join(fields[3:], " ")
 			case "Name":
 				raidInfo.Name = strings.Join(fields[2:], " ")
 			case "UUID":

+ 1 - 72
storage.pool.go

@@ -321,8 +321,7 @@ func HandleFSHToggle(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	//Give it some time to finish unloading
-	time.Sleep(1 * time.Second)
+	targetFSH.Closed = !targetFSH.Closed
 
 	//Return ok
 	utils.SendOK(w)
@@ -544,76 +543,6 @@ func buildOptionFromRequestForm(payload string) (fs.FileSystemOption, error) {
 	return newFsOption, nil
 }
 
-/*
-func HandleStorageNewFsHandler(w http.ResponseWriter, r *http.Request) {
-	newFsOption, _ := buildOptionFromRequestForm(r)
-
-	type errorObject struct {
-		Message string
-		Source  string
-	}
-
-	//Get group from form data
-	groupName := r.FormValue("group")
-
-	//Check if group exists
-	if !permissionHandler.GroupExists(groupName) && groupName != "system" {
-		js, _ := json.Marshal(errorObject{
-			Message: "Group not exists: " + groupName,
-			Source:  "",
-		})
-		http.Redirect(w, r, "../../../SystemAO/storage/error.html#"+string(js), 307)
-	}
-
-	//Validate the config
-	err := fs.ValidateOption(&newFsOption)
-	if err != nil {
-		//Serve an error page
-		js, _ := json.Marshal(errorObject{
-			Message: err.Error(),
-			Source:  groupName,
-		})
-		http.Redirect(w, r, "../../../SystemAO/storage/error.html#"+string(js), 307)
-		return
-	}
-
-	//Ok. Append to the record
-	configFile := "./system/storage.json"
-	if groupName != "system" {
-		configFile = "./system/storage/" + groupName + ".json"
-	}
-
-	//If file exists, merge it to
-	oldConfigs := []fs.FileSystemOption{}
-	if fs.FileExists(configFile) {
-		originalConfigFile, _ := os.ReadFile(configFile)
-		err := json.Unmarshal(originalConfigFile, &oldConfigs)
-		if err != nil {
-			systemWideLogger.PrintAndLog(err,nil)
-		}
-	}
-
-	oldConfigs = append(oldConfigs, newFsOption)
-
-	//Prepare the content to be written
-	js, _ := json.Marshal(oldConfigs)
-	resultingJson := pretty.Pretty(js)
-
-	err = os.WriteFile(configFile, resultingJson, 0775)
-	if err != nil {
-		//Write Error. This could sometime happens on Windows host for unknown reason
-		js, _ := json.Marshal(errorObject{
-			Message: err.Error(),
-			Source:  groupName,
-		})
-		http.Redirect(w, r, "../../../SystemAO/storage/error.html#"+string(js), 307)
-		return
-	}
-	w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
-	http.Redirect(w, r, "../../../SystemAO/storage/poolEditor.html#"+groupName, 307)
-}
-*/
-
 func HandleListStoragePoolsConfig(w http.ResponseWriter, r *http.Request) {
 	target, _ := utils.GetPara(r, "target")
 	if target == "" {