cleanup: remove 2,369 lines of dead code
Removed backup files and unused legacy scanner function. All code verified as unreferenced.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -324,3 +325,46 @@ func (q *AgentQueries) UpdateAgentUpdatingStatus(id uuid.UUID, isUpdating bool,
|
||||
_, err := q.db.Exec(query, isUpdating, versionPtr, time.Now(), id)
|
||||
return err
|
||||
}
|
||||
|
||||
// CompleteAgentUpdate marks an agent update as successful and updates version
|
||||
func (q *AgentQueries) CompleteAgentUpdate(agentID string, newVersion string) error {
|
||||
query := `
|
||||
UPDATE agents
|
||||
SET
|
||||
current_version = $2,
|
||||
is_updating = false,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
result, err := q.db.ExecContext(ctx, query, agentID, newVersion)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to complete agent update: %w", err)
|
||||
}
|
||||
|
||||
rows, err := result.RowsAffected()
|
||||
if err != nil || rows == 0 {
|
||||
return fmt.Errorf("agent not found or version not updated")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetAgentUpdating marks an agent as updating with nonce
|
||||
func (q *AgentQueries) SetAgentUpdating(agentID string, isUpdating bool, targetVersion string) error {
|
||||
query := `
|
||||
UPDATE agents
|
||||
SET is_updating = $2, updating_to_version = $3, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
_, err := q.db.Exec(query, agentID, isUpdating, targetVersion)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set agent updating state: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user