Conversation
|
(当初 GitHub Releases API にハッシュ値が含まれてるかと淡い期待を抱きましたが、流石にそれはなかったので仕方なく都度 fetch して調べるようにしました) |
|
vital.vim で vim-jp/redirects に fetch してるスクリプトがありますが、http やオレオレ証明書だと 試したスクリプト結果 |
あとソースコード的なレビュー追加しておきます。 |
| } | ||
|
|
||
| func updateRedirect(d redirect, a *github.Asset) error { | ||
| func updateRedirect(d redirect, a *github.Asset, bin io.ReadCloser) error { |
There was a problem hiding this comment.
io.ReadCloser を渡すのではなく、この関数のなかでDLしたほうが良い。
Asset の中身だけを見て Redirect を更新するかどうかを決定し、更新時にのみ本体をDLする
という理想形に近づけておくため。
| return nil | ||
| } | ||
|
|
||
| func calcSha1Hash(r io.ReadCloser) (string, error) { |
There was a problem hiding this comment.
この用途なら引数は io.Reader で十分。
ただし複数の hash アルゴリズムに渡すことを考慮するなら単に []byte で良い。
ガチなら io.TeeReader を挟むのだが…
| } | ||
| } | ||
|
|
||
| func fetchReleaseBinary(a *github.Asset) (io.ReadCloser, error) { |
There was a problem hiding this comment.
関数名は downloadAsset(*github.Asset) もしくは fetchURL(string) のが良いだろう。
| } | ||
|
|
||
| func fetchReleaseBinary(a *github.Asset) (io.ReadCloser, error) { | ||
| resp, err := http.DefaultClient.Get(a.DownloadURL) |
There was a problem hiding this comment.
特にクライアントをいじる気がないなら http.Get() を使う。
Fixes #8
#8 を実装してみました。
以下3点について相談させてください。
_data/redirects.ymlにgithub_releaseが書かれてない過去や安定版のリリースについては手動で調べて追記する必要があります。ちなみにスクリプトを実行 +
jekyll serve後はこんな感じになります。スクリーンショット
実行後の差分