diff options
| author | historia <[not public]> | 2026-09-16 15:00:46 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-16 15:00:46 -0400 |
| commit | a6cf03a6ae98e4fb675da25046d148e92bcf7206 (patch) | |
| tree | 194499fe9e696be8c31cd915b7ad92678f9f95e0 /internal/admin/undo.go | |
| parent | 9192d94dea6be5498ab080f3e2df5667af871d7a (diff) | |
| download | thehouseoficarus-a6cf03a6ae98e4fb675da25046d148e92bcf7206.tar.gz | |
chore: staticcheck and gofmt cleanups
Diffstat (limited to 'internal/admin/undo.go')
| -rw-r--r-- | internal/admin/undo.go | 67 |
1 files changed, 0 insertions, 67 deletions
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() |
