Skip to content

Commit

Permalink
Merge pull request #341 from privacybydesign/fix-timestamp-panics
Browse files Browse the repository at this point in the history
Fix: panics occur when the timestamp file does not exist in a scheme …
  • Loading branch information
ivard authored Sep 5, 2023
2 parents 29a64fe + 8c6dca4 commit 94e07c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Fixed
- Auto-update mechanism of IRMA configuration not working in ghcr.io/privacybydesign/irma Docker container
- Panics occur when the timestamp file does not exist in a scheme directory

## [0.13.2] - 2023-08-22
### Changed
Expand Down
15 changes: 11 additions & 4 deletions schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,11 @@ func (conf *Configuration) parseSchemeDescription(dir string) (Scheme, SchemeMan

var ts *Timestamp
ts, exists, err = readTimestamp(filepath.Join(dir, "timestamp"))
if err != nil || !exists {
return scheme, SchemeManagerStatusParsingError, WrapErrorPrefix(err, "Could not read scheme manager timestamp")
if err != nil {
return scheme, SchemeManagerStatusParsingError, WrapErrorPrefix(err, "could not read scheme manager timestamp")
}
if !exists {
return scheme, SchemeManagerStatusParsingError, errors.New("scheme manager timestamp not found")
}
scheme.setTimestamp(*ts)

Expand Down Expand Up @@ -630,9 +633,13 @@ func (conf *Configuration) isUpToDate(subdir string) (bool, error) {
return true, nil
}
newTime, exists, err := readTimestamp(filepath.Join(conf.assets, subdir, "timestamp"))
if err != nil || !exists {
return true, WrapErrorPrefix(err, "Could not read asset timestamp of scheme "+subdir)
if err != nil {
return true, WrapErrorPrefix(err, "could not read asset timestamp of scheme "+subdir)
}
if !exists {
return true, errors.Errorf("no timestamp found for scheme %s", subdir)
}

// The storage version of the manager does not need to have a timestamp. If it does not, it is outdated.
oldTime, exists, err := readTimestamp(filepath.Join(conf.Path, subdir, "timestamp"))
if err != nil {
Expand Down

0 comments on commit 94e07c4

Please sign in to comment.