Add creation of audio directory and remove unused function in download package
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user