archive

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package archive manages the task archive store (.cloop/archive.json). Archived tasks are removed from the active plan and stored here with a timestamp so the plan stays lean for long-running projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(workDir string, tasks []ArchivedTask) error

Save persists the archive to disk atomically.

The previous tmp+rename hand-roll skipped fsync of both the data file and the parent directory; on power loss the rename could be lost (leaving the previous file) or — worse — the new file could exist on disk but the dirent could be missing, leaving neither the old nor the new archive visible. atomicfile.Write fsyncs both the data file and the parent directory's inode, so the rename survives a power loss.

Types

type ArchivedTask

type ArchivedTask struct {
	Task       pm.Task   `json:"task"`
	ArchivedAt time.Time `json:"archived_at"`
}

ArchivedTask wraps a pm.Task with the timestamp it was archived.

func ArchiveTasks

func ArchiveTasks(plan *pm.Plan, existing []ArchivedTask, ids []int, all bool) ([]ArchivedTask, error)

ArchiveTasks moves tasks matching ids (or all terminal tasks when all=true) from plan into the archive. The plan is mutated in place; the caller must persist the plan and the returned archive slice.

Returns the newly archived entries and an error if any requested ID is missing or not in a terminal state.

func Load

func Load(workDir string) ([]ArchivedTask, error)

Load reads the archive from disk. Returns an empty slice when the file does not exist (normal for a new project).

On parse failure (zero-byte file from a pre-atomicfile torn write, manual edit gone wrong, schema drift) the corrupt file is quarantined aside as archive.json.corrupt-<unix> and a nil slice is returned. The next archive operation will reseed the file from scratch — losing the historical archive is preferable to hard-failing `cloop task archive`, `cloop task unarchive`, and any search/report path that calls Load (e.g. pkg/search/search.go).

func UnarchiveTask

func UnarchiveTask(plan *pm.Plan, existing []ArchivedTask, id int) (*pm.Task, []ArchivedTask, error)

UnarchiveTask moves the task with the given ID from the archive back into the plan with status reset to pending. Returns the restored task.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL