Fixes the md5 check so that it only runs if it was able to download the

checksum file and parse it. Also changes a failing checksum to move the
file to the same name with a .bk extension.
This commit is contained in:
Kevin Ruffin 2022-03-06 21:17:29 -05:00
parent 994883c588
commit f631a23ae8

View File

@ -288,7 +288,7 @@ func writeBashScript(dl *DownloadLinks, folder string, scriptName string, produc
line += "wget --no-clobber --continue --quiet --show-progress -O \"" + file + ".xml\" \"" + dl.Checksum + "\"\n"
line += "wget --no-clobber --continue --quiet --show-progress -O \"" + file + "\" \"" + dl.Downlink + "\"\n"
line += "[ ! -f \"" + file + ".md5\" ] && cat \"" + file + ".xml\" | tr '\\n' '\\r' | sed -E 's|<file name=\"([^\"]+)\".*md5=\"([^\"]+).*|\\2 " + file + "\\n|' > " + file + ".md5\n"
line += "! md5sum -c \"" + file + ".md5\" && rm \"" + file + "\" && echo \"Removed unmatched file: " + file + "\"\n"
line += "[ -f \"" + file + ".md5\" ] && ! md5sum -c \"" + file + ".md5\" && mv \"" + file + "\" \"" + file + ".bk\" && echo \"Removed unmatched file: " + file + "\"\n"
f, err := os.OpenFile("./" + scriptName, os.O_APPEND|os.O_WRONLY, 0664)
if err != nil {