Skip to content

Commit

Permalink
Merge pull request #41 from TheCacophonyProject/fix-deleting-audio-file
Browse files Browse the repository at this point in the history
Fix deleting audio file
  • Loading branch information
CameronRP authored Mar 14, 2021
2 parents e455c9c + 7958e92 commit 1a21b86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ nfpms:
bindir: /usr/bin
files:
"_release/audiobait.service": "/etc/systemd/system/audiobait.service"
scripts:
postinstall: "_release/postinstall.sh"
4 changes: 4 additions & 0 deletions _release/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
systemctl daemon-reload
systemctl enable audiobait.service
systemctl restart audiobait.service
2 changes: 1 addition & 1 deletion downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (dl *Downloader) downloadAudioFile(api *api.CacophonyAPI, fileID int, fileR
}
if !dl.validateSoundFile(filepath.Join(dl.audioDir, filename), fileResp.FileSize) {
log.Printf("%s is not valid. Removing from disk.", filename)
if err := os.Remove(filename); err != nil {
if err := os.Remove(filepath.Join(dl.audioDir, filename)); err != nil {
return fmt.Errorf("could not remove file: %v", err)
}
return errors.New("download was not valid")
Expand Down

0 comments on commit 1a21b86

Please sign in to comment.