X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=file.go;h=c7e580990d7ba54ada969e6d454acecc54c07704;hb=1002c514a8530bb6608c556b4446e853be390917;hp=e06a9bce335ccc4e4444e5f8ea9502d27df09eba;hpb=44a325a9bea5f53c6489cecb3691709306a1814c;p=nsscash%2Fnsscash.git diff --git a/file.go b/file.go index e06a9bc..c7e5809 100644 --- a/file.go +++ b/file.go @@ -1,6 +1,6 @@ // Download and write files atomically to the file system -// Copyright (C) 2019 Simon Ruderich +// Copyright (C) 2019-2020 Simon Ruderich // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -89,12 +89,17 @@ func fetchFile(file *File, state *State) error { t = zero // force download } + oldT := t status, body, err := fetchIfModified(file.Url, file.Username, file.Password, file.CA, &t) if err != nil { return err } if status == http.StatusNotModified { + if oldT.IsZero() { + return fmt.Errorf("status code 304 " + + "but did not send If-Modified-Since") + } log.Printf("%q -> %q: not modified", file.Url, file.Path) return nil }