From cf04e386e85239b8698734b68742ebbe7d7387a7 Mon Sep 17 00:00:00 2001 From: Robert Pendell Date: Thu, 18 Jan 2024 13:22:46 -0500 Subject: [PATCH] Fixing the CreateVolumeDir option Apply upstream PR https://github.com/metafates/mangal/pull/194 --- source/chapter.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/chapter.go b/source/chapter.go index 2db74035..dcd50a5e 100644 --- a/source/chapter.go +++ b/source/chapter.go @@ -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 @@ -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 {