Skip to content

Commit

Permalink
Fixes #112: avoid folder nesting when an image download fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Girbons committed May 22, 2022
1 parent 2378e17 commit ebd6cf4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[Changes][v0.33.2]
<a name="v0.33.2"></a>

# [0.33.2 (v0.33.2)](https://github.com/Girbons/comics-downloader/releases/tag/v0.33.2) - 22 May 2022

# Fixes

- #112: Fixed issue when a broken image is downloaded.

[Changes][v0.33.1]
<a name="v0.33.1"></a>

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

Download the latest release:

- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader.exe)
- [Linux ARM](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-linux-arm)
- [Linux ARM64](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-linux-arm64)
- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader.exe)
- [Linux ARM](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-linux-arm)
- [Linux ARM64](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-linux-arm64)

Download the latest GUI release:

- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-gui)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-gui-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.1/comics-downloader-gui-windows.exe)
- [Linux](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui)
- [Mac OSX](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui-osx)
- [Windows](https://github.com/Girbons/comics-downloader/releases/download/v0.33.2/comics-downloader-gui-windows.exe)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// Tag specifies the current release tag.
// It needs to be manually updated.
const Tag = "v0.33.1"
const Tag = "v0.33.2"

// IsNewAvailable will fetch the latest project releases
// and will compare the latest release Tag against the current Tag.
Expand Down
8 changes: 5 additions & 3 deletions pkg/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func (comic *Comic) DownloadImages(options *config.Options) (string, error) {
if err != nil {
return dir, err
}

// setup the progress bar
bar := progressbar.NewOptions(len(comic.Links), progressbar.OptionSetRenderBlankState(true))

Expand Down Expand Up @@ -284,15 +283,18 @@ func (comic *Comic) DownloadImages(options *config.Options) (string, error) {
}
defer rsp.Body.Close()

imgFile, err := os.Create(fmt.Sprintf("%04d-image.%s", i, format))
imgName := fmt.Sprintf("%04d-image.%s", i, format)
imgFile, err := os.Create(imgName)
if err != nil {
return err
}
defer imgFile.Close()

err = util.SaveImage(imgFile, rsp.Body, format)
if err != nil {
return err
msgError := fmt.Sprintf("There was an error while downloading image number: %d - comic issue: %s", i, comic.IssueNumber)
options.Logger.Error(msgError)
os.Remove(imgName)
}

if barErr := bar.Add(1); barErr != nil {
Expand Down

0 comments on commit ebd6cf4

Please sign in to comment.