X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=state.go;h=fa8dccd60cfb56974f6a03d58eedae5c06f76b0f;hp=b0dec1c2d47673fffa5eb81ee8e3d3113fce689f;hb=b8abeed6c7bddb9d9770f3be93dc41400354783b;hpb=5a6b8152cf4c9fcd71b875ff5dce1ec0fad9c9d4 diff --git a/state.go b/state.go index b0dec1c..fa8dccd 100644 --- a/state.go +++ b/state.go @@ -22,15 +22,11 @@ import ( "io/ioutil" "os" "path/filepath" - "reflect" "time" ) type State struct { LastModified map[string]time.Time - - // Copy of LastModified to write the state file only on changes - origLastModified map[string]time.Time } func LoadState(path string) (*State, error) { @@ -54,19 +50,13 @@ func LoadState(path string) (*State, error) { state.LastModified = make(map[string]time.Time) } - state.origLastModified = make(map[string]time.Time) - for k, v := range state.LastModified { - state.origLastModified[k] = v - } - return &state, nil } -func WriteStateIfChanged(path string, state *State) error { - // State hasn't changed, nothing to do - if reflect.DeepEqual(state.LastModified, state.origLastModified) { - return nil - } +func WriteState(path string, state *State) error { + // Update the state file even if nothing has changed to provide a + // simple way to check if nsscash ran successfully (the state is only + // updated if there were no errors) x, err := json.Marshal(state) if err != nil {