diff options
Diffstat (limited to 'src/plugins/LocalManga.cpp')
-rw-r--r-- | src/plugins/LocalManga.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/LocalManga.cpp b/src/plugins/LocalManga.cpp index fa0df27..21e8780 100644 --- a/src/plugins/LocalManga.cpp +++ b/src/plugins/LocalManga.cpp @@ -83,7 +83,7 @@ namespace QuickMedia { // Pages are sorted from 1.png to n.png static std::vector<LocalMangaPage> get_images_in_manga(const Path &directory) { std::vector<LocalMangaPage> page_list; - for_files_in_dir(directory, [&page_list](const Path &filepath, FileType file_type) -> bool { + for_files_in_dir(directory, [&page_list](const Path &filepath, FileType file_type, time_t) -> bool { if(file_type != FileType::REGULAR) return true; @@ -107,7 +107,7 @@ namespace QuickMedia { static std::vector<LocalMangaChapter> get_chapters_in_manga(std::string manga_name, const Path &directory, bool only_include_latest, bool include_pages, bool only_get_coverpage = false) { std::vector<LocalMangaChapter> chapter_list; - auto callback = [&chapter_list, &manga_name, only_include_latest, include_pages, only_get_coverpage](const Path &filepath, FileType file_type) -> bool { + auto callback = [&chapter_list, &manga_name, only_include_latest, include_pages, only_get_coverpage](const Path &filepath, FileType file_type, time_t last_modified_seconds) -> bool { if(file_type != FileType::DIRECTORY) return true; @@ -130,8 +130,11 @@ namespace QuickMedia { } } - if(!only_get_coverpage) - file_get_last_modified_time_seconds(filepath.data.c_str(), &local_manga_chapter.modified_time_seconds); + if(!only_get_coverpage) { + if(last_modified_seconds == 0) + file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds); + local_manga_chapter.modified_time_seconds = last_modified_seconds; + } chapter_list.push_back(std::move(local_manga_chapter)); return only_include_latest ? false : true; @@ -147,16 +150,20 @@ namespace QuickMedia { static std::vector<LocalManga> get_manga_in_directory(const Path &directory, bool only_get_coverpage) { std::vector<LocalManga> manga_list; - auto callback = [&manga_list, only_get_coverpage](const Path &filepath, FileType file_type) -> bool { + auto callback = [&manga_list, only_get_coverpage](const Path &filepath, FileType file_type, time_t last_modified_seconds) -> bool { if(file_type != FileType::DIRECTORY) return true; LocalManga local_manga; local_manga.name = filepath.filename(); local_manga.chapters = get_chapters_in_manga(local_manga.name, filepath, true, false, only_get_coverpage); - if(local_manga.chapters.empty() || !file_get_last_modified_time_seconds(filepath.data.c_str(), &local_manga.modified_time_seconds)) + if(local_manga.chapters.empty()) return true; + if(last_modified_seconds == 0) + file_get_last_modified_time_seconds(filepath.data.c_str(), &last_modified_seconds); + local_manga.modified_time_seconds = last_modified_seconds; + manga_list.push_back(std::move(local_manga)); return true; }; |