Skip to content
Snippets Groups Projects
Commit 6eb0ed68 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Manager: /depsgraph: store & use Last-Modified header contents as string

When querying Server .../depsgraph, we just take the Last-Modified header
value as string, and store that without doing any parsing. This prevents
issues with timezones getting lost, formatting going wrong, etc.
parent fa70da03
No related branches found
No related tags found
No related merge requests found
......@@ -105,7 +105,7 @@ type MayKeepRunningResponse struct {
// Settings we want to be able to update from within Flamenco Manager itself,
// so those are stored in MongoDB itself.
type SettingsInMongo struct {
DepsgraphLastModified *time.Time `bson:"depsgraph_last_modified"`
DepsgraphLastModified *string `bson:"depsgraph_last_modified"`
}
type StatusReport struct {
......
......@@ -158,9 +158,8 @@ func download_tasks_from_upstream(config *Conf, mongo_sess *mgo.Session) {
settings := GetSettings(db)
if settings.DepsgraphLastModified != nil {
log.Infof("Getting tasks from upstream Flamenco %s If-Modified-Since %s", get_url,
settings.DepsgraphLastModified)
req.Header.Set("If-Modified-Since",
settings.DepsgraphLastModified.Format(LastModifiedHeaderFormat))
*settings.DepsgraphLastModified)
req.Header.Set("If-Modified-Since", *settings.DepsgraphLastModified)
} else {
log.Infof("Getting tasks from upstream Flamenco %s", get_url)
}
......@@ -227,12 +226,8 @@ func download_tasks_from_upstream(config *Conf, mongo_sess *mgo.Session) {
last_modified := resp.Header.Get("Last-Modified")
if last_modified != "" {
log.Info("Last modified task was at ", last_modified)
if parsed, err := time.Parse(LastModifiedHeaderFormat, last_modified); err != nil {
log.Errorf("Unable to parse Last-Modified header: ", err)
} else {
settings.DepsgraphLastModified = &parsed
SaveSettings(db, settings)
}
settings.DepsgraphLastModified = &last_modified
SaveSettings(db, settings)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment