Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: panics occur when the timestamp file does not exist in a scheme … #341

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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