replace tape library body layout

This commit is contained in:
Warp Agent
2025-12-26 16:36:47 +00:00
parent 419fcb7625
commit 5e63ebc9fe
11 changed files with 1523 additions and 180 deletions

View File

@@ -1,6 +1,7 @@
package storage
import (
"context"
"fmt"
"net/http"
"strings"
@@ -42,9 +43,9 @@ func NewHandler(db *database.DB, log *logger.Logger) *Handler {
}
}
// ListDisks lists all physical disks
// ListDisks lists all physical disks from database
func (h *Handler) ListDisks(c *gin.Context) {
disks, err := h.diskService.DiscoverDisks(c.Request.Context())
disks, err := h.diskService.ListDisksFromDatabase(c.Request.Context())
if err != nil {
h.logger.Error("Failed to list disks", "error", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list disks"})
@@ -70,15 +71,19 @@ func (h *Handler) SyncDisks(c *gin.Context) {
// Run sync in background
go func() {
ctx := c.Request.Context()
// Create new context for background task (don't use request context which may expire)
ctx := context.Background()
h.taskEngine.StartTask(ctx, taskID)
h.taskEngine.UpdateProgress(ctx, taskID, 50, "Discovering disks...")
h.logger.Info("Starting disk sync", "task_id", taskID)
if err := h.diskService.SyncDisksToDatabase(ctx); err != nil {
h.logger.Error("Disk sync failed", "task_id", taskID, "error", err)
h.taskEngine.FailTask(ctx, taskID, err.Error())
return
}
h.logger.Info("Disk sync completed", "task_id", taskID)
h.taskEngine.UpdateProgress(ctx, taskID, 100, "Disk sync completed")
h.taskEngine.CompleteTask(ctx, taskID, "Disks synchronized successfully")
}()