mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: sqlite storage
This commit is contained in:
@@ -2,8 +2,10 @@ package driver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"ironmount/internal/db"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Remove(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -12,6 +14,17 @@ func Remove(w http.ResponseWriter, r *http.Request) {
|
||||
var req RemoveRequest
|
||||
_ = json.NewDecoder(r.Body).Decode(&req)
|
||||
|
||||
delete(volumes, req.Name)
|
||||
vol, err := db.GetVolumeByName(req.Name)
|
||||
if err != nil {
|
||||
log.Printf("Error retrieving volume: %s", err.Error())
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{
|
||||
"Err": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
db.RemoveVolume(vol.Name)
|
||||
os.RemoveAll(vol.Path)
|
||||
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"Err": ""})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user