Skip to content

Commit

Permalink
Fixing the CreateVolumeDir option
Browse files Browse the repository at this point in the history
Apply upstream PR metafates#194
  • Loading branch information
shinji257 committed Jan 18, 2024
1 parent 8ec34d9 commit cf04e38
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions source/chapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,22 @@ func (c *Chapter) IsDownloaded() bool {
return c.isDownloaded.MustGet()
}

path, _ := c.path(c.Manga.peekPath(), false)
path, _ := c.path(c.Manga.peekPath())
exists, _ := filesystem.Api().Exists(path)
c.isDownloaded = mo.Some(exists)
return exists
}

func (c *Chapter) path(relativeTo string, createVolumeDir bool) (path string, err error) {
if createVolumeDir {
path = filepath.Join(path, util.SanitizeFilename(c.Volume))
func (c *Chapter) path(relativeTo string) (path string, err error) {
if c.Volume != "" && viper.GetBool(key.DownloaderCreateVolumeDir) {
path = filepath.Join(relativeTo, util.SanitizeFilename(c.Volume))
err = filesystem.Api().MkdirAll(path, os.ModePerm)
if err != nil {
return
}
}
path = filepath.Join(path, c.Filename())
return
}

path = filepath.Join(relativeTo, c.Filename())
return
Expand All @@ -166,7 +168,7 @@ func (c *Chapter) Path(temp bool) (path string, err error) {
return
}

return c.path(manga, c.Volume != "" && viper.GetBool(key.DownloaderCreateVolumeDir))
return c.path(manga)
}

func (c *Chapter) Source() Source {
Expand Down

0 comments on commit cf04e38

Please sign in to comment.