From 17e6368a9096efb5bd00e7c8b3e20f0a162d6737 Mon Sep 17 00:00:00 2001 From: linvegas Date: Mon, 25 Dec 2023 23:14:15 -0300 Subject: [PATCH 1/3] fix: create sub-directories for volumes --- source/chapter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/chapter.go b/source/chapter.go index 2db74035..76e169e8 100644 --- a/source/chapter.go +++ b/source/chapter.go @@ -148,11 +148,13 @@ func (c *Chapter) IsDownloaded() bool { func (c *Chapter) path(relativeTo string, createVolumeDir bool) (path string, err error) { if createVolumeDir { - path = filepath.Join(path, util.SanitizeFilename(c.Volume)) + 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()) From 77438b8dea9f563a2c441684291bf3b1f8ac6b41 Mon Sep 17 00:00:00 2001 From: linvegas Date: Mon, 25 Dec 2023 23:42:32 -0300 Subject: [PATCH 2/3] fix: check if chapter is downloaded when vol dir key is on --- source/chapter.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/chapter.go b/source/chapter.go index 76e169e8..e0554f94 100644 --- a/source/chapter.go +++ b/source/chapter.go @@ -140,14 +140,14 @@ 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 { +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 { @@ -155,7 +155,7 @@ func (c *Chapter) path(relativeTo string, createVolumeDir bool) (path string, er } path = filepath.Join(path, c.Filename()) return - } + } path = filepath.Join(relativeTo, c.Filename()) return @@ -168,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 { From 053d3e6cd016d226cb15f875275d96fcc4c10bd3 Mon Sep 17 00:00:00 2001 From: linvegas Date: Mon, 25 Dec 2023 23:53:09 -0300 Subject: [PATCH 3/3] tab indentation fix --- source/chapter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter.go b/source/chapter.go index e0554f94..dcd50a5e 100644 --- a/source/chapter.go +++ b/source/chapter.go @@ -147,7 +147,7 @@ func (c *Chapter) IsDownloaded() bool { } func (c *Chapter) path(relativeTo string) (path string, err error) { - if c.Volume != "" && viper.GetBool(key.DownloaderCreateVolumeDir) { + 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 {