Add creation of audio directory and remove unused function in download package

This commit is contained in:
NeilClack
2026-06-27 14:25:25 -05:00
parent fce5286d86
commit 2c88b7ffc5
5 changed files with 29 additions and 44 deletions
+7
View File
@@ -189,6 +189,13 @@ func Run() {
audioDir := filepath.Join(config.AssetsDir, "audio")
_, err = os.Stat(audioDir)
if os.IsNotExist(err) {
if err = os.MkdirAll(audioDir, 0740); err != nil {
logger.Error("unable to create audio directory: %v", err)
}
}
go download.DownloadAudioFiles(app.PageRouter.Context.MessageChannel, audioDir, "https://files.radiantwavetech.com/audio/")
app.runEventLoop()
-13
View File
@@ -194,19 +194,6 @@ func fileMD5(path string) (string, error) {
return fmt.Sprintf("%x", h.Sum(nil)), nil
}
// remoteFileSize does a HEAD request and returns Content-Length.
func remoteFileSize(url string) (int64, error) {
resp, err := http.Head(url)
if err != nil {
return 0, err
}
resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("HEAD %s: %s", url, resp.Status)
}
return resp.ContentLength, nil
}
// downloadFile streams url to destPath, calling onChunk(n) after each write
// with the number of bytes just written. Returns total bytes downloaded.
func downloadFile(url, destPath string, onChunk func(int64)) (int64, error) {