Fix: UI not refreshing after ZFS pool operations due to caching
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package httpapp
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -76,6 +78,12 @@ func (a *App) handleCreatePool(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Invalidate cache for GET /api/v1/pools
|
||||
keyToInvalidate := "GET:/api/v1/pools"
|
||||
hash := sha256.Sum256([]byte(keyToInvalidate))
|
||||
cacheKey := hex.EncodeToString(hash[:])
|
||||
a.cache.Invalidate(cacheKey)
|
||||
|
||||
pool, err := a.zfs.GetPool(req.Name)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusCreated, map[string]string{"message": "pool created", "name": req.Name})
|
||||
@@ -114,6 +122,12 @@ func (a *App) handleDeletePool(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Invalidate cache for GET /api/v1/pools
|
||||
keyToInvalidate := "GET:/api/v1/pools"
|
||||
hash := sha256.Sum256([]byte(keyToInvalidate))
|
||||
cacheKey := hex.EncodeToString(hash[:])
|
||||
a.cache.Invalidate(cacheKey)
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]string{"message": "pool destroyed", "name": name})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user