state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FileName = "_state.json"

FileName is the name of the state file in each blog directory.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostEntry

type PostEntry struct {
	Title         string `json:"title"`
	DirName       string `json:"dirName"`
	DownloadedAt  string `json:"downloadedAt"`
	UpdatedAt     int64  `json:"updatedAt,omitempty"`
	CommentsCount int    `json:"commentsCount"`
	Price         int    `json:"price"`
	Tier          string `json:"tier,omitempty"`
	Locked        bool   `json:"locked,omitempty"`
	HasComments   bool   `json:"hasComments"`
	HasMd         bool   `json:"hasMd"`
}

PostEntry records metadata about a downloaded post.

type State

type State struct {
	Posts    map[string]PostEntry `json:"posts"`
	LastSync string               `json:"lastSync"`
	// contains filtered or unexported fields
}

State tracks which posts have been downloaded for a blog.

func Load

func Load(dir string) *State

Load reads the state file from the given directory. Returns an empty state if the file doesn't exist or is invalid.

func (*State) Add

func (s *State) Add(postID string, entry PostEntry)

Add records a downloaded post in the state.

func (*State) Count

func (s *State) Count() int

Count returns the number of tracked posts.

func (*State) Get

func (s *State) Get(postID string) (PostEntry, bool)

Get returns the post entry for the given ID.

func (*State) Has

func (s *State) Has(postID string) bool

Has reports whether a post ID exists in the state.

func (*State) Save

func (s *State) Save() error

Save writes the state to disk.

Jump to

Keyboard shortcuts

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