diff --git a/cmd/dkl-store-upload/main.go b/cmd/dkl-store-upload/main.go index fd04351..f6ddf6c 100644 --- a/cmd/dkl-store-upload/main.go +++ b/cmd/dkl-store-upload/main.go @@ -30,6 +30,8 @@ func main() { in, err := os.Open(inPath) fail(err) + defer in.Close() + // hash the file log.Print("hashing...") h := sha1.New() @@ -40,6 +42,18 @@ func main() { log.Print("SHA1 of source: ", sha1Hex) + // check remote + head, err := http.Head(outURL) + fail(err) + + if head.StatusCode == 200 { + remoteSHA1 := head.Header.Get("X-Content-SHA1") + if sha1Hex == remoteSHA1 { + log.Print("remote is already up-to-date") + return + } + } + // rewind _, err = in.Seek(0, os.SEEK_SET) fail(err) diff --git a/modd.conf b/modd.conf new file mode 100644 index 0000000..9996a60 --- /dev/null +++ b/modd.conf @@ -0,0 +1,4 @@ +**/*.go go.* { + prep: go test ./... + prep: go install ./cmd/... +}