From a6cf03a6ae98e4fb675da25046d148e92bcf7206 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 16 Sep 2026 15:00:46 -0400 Subject: chore: staticcheck and gofmt cleanups --- internal/admin/undo.go | 67 -------------------------------------------------- 1 file changed, 67 deletions(-) (limited to 'internal/admin/undo.go') diff --git a/internal/admin/undo.go b/internal/admin/undo.go index 98d8d9a..51610f8 100644 --- a/internal/admin/undo.go +++ b/internal/admin/undo.go @@ -414,73 +414,6 @@ func (us *UndoStack) save() { } } -func (us *UndoStack) load() { - data, err := os.ReadFile(us.filePath) - if err != nil { - return - } - log.Printf("undo: loaded history from %s", us.filePath) - type extraEntry struct { - FilePath string `json:"file_path"` - NewFilePath string `json:"new_file_path,omitempty"` - OldContent string `json:"old_content"` - NewContent string `json:"new_content"` - IsDelete bool `json:"is_delete,omitempty"` - IsCreate bool `json:"is_create,omitempty"` - } - type entry struct { - Time string `json:"time"` - Description string `json:"description"` - FilePath string `json:"file_path"` - NewFilePath string `json:"new_file_path,omitempty"` - OldContent string `json:"old_content"` - NewContent string `json:"new_content"` - IsDelete bool `json:"is_delete"` - IsCreate bool `json:"is_create"` - ExtraFiles []extraEntry `json:"extra_files,omitempty"` - IDMap map[int]int `json:"id_map,omitempty"` - } - var saveData struct { - History []entry `json:"history"` - Redo []entry `json:"redo"` - } - if err := json.Unmarshal(data, &saveData); err != nil { - log.Printf("undo: failed to unmarshal history: %v", err) - return - } - fromEntries := func(entries []entry) []ChangeDesc { - var changes []ChangeDesc - for _, e := range entries { - var extra []ExtraFile - for _, ef := range e.ExtraFiles { - extra = append(extra, ExtraFile{ - FilePath: ef.FilePath, - NewFilePath: ef.NewFilePath, - OldContent: []byte(ef.OldContent), - NewContent: []byte(ef.NewContent), - IsDelete: ef.IsDelete, - IsCreate: ef.IsCreate, - }) - } - changes = append(changes, ChangeDesc{ - Time: e.Time, - Description: e.Description, - FilePath: e.FilePath, - NewFilePath: e.NewFilePath, - OldContent: []byte(e.OldContent), - NewContent: []byte(e.NewContent), - IsDelete: e.IsDelete, - IsCreate: e.IsCreate, - ExtraFiles: extra, - IDMap: e.IDMap, - }) - } - return changes - } - us.history = fromEntries(saveData.History) - log.Printf("undo: loaded %d history entries", len(us.history)) -} - func (us *UndoStack) Clear() { us.mu.Lock() defer us.mu.Unlock() -- cgit v1.2.3