소스 검색

Allow whitespaces in downloads path and add chapter id to avoid path conflicts. Throw if page list is empty
WARNING: Downloaded chapters from a previous version won't be visible in the app anymore. You will have to manually delete the folder and download them again.

inorichi 9 년 전
부모
커밋
226cc6990d

+ 0 - 1
app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java

@@ -253,7 +253,6 @@ public class DatabaseHelper {
                 .filter(c -> !dbChapters.contains(c))
                 .doOnNext(c -> {
                     c.manga_id = manga.id;
-                    c.date_fetch = new Date().getTime();
                     ChapterRecognition.parseChapterNumber(c, manga);
                 })
                 .toList();

+ 3 - 3
app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java

@@ -164,7 +164,7 @@ public class DownloadManager {
 
     // Check that all the images are downloaded
     private boolean isChapterDownloaded(File directory, List<Page> pages) {
-        return pages != null && pages.size() + 1 == directory.listFiles().length;
+        return pages != null && !pages.isEmpty() && pages.size() + 1 == directory.listFiles().length;
     }
 
     // Download the entire chapter
@@ -359,9 +359,9 @@ public class DownloadManager {
     public File getAbsoluteChapterDirectory(Source source, Manga manga, Chapter chapter) {
         String chapterRelativePath = source.getName() +
                 File.separator +
-                manga.title.replaceAll("[^a-zA-Z0-9.-]", "_") +
+                manga.title.replaceAll("[^\\sa-zA-Z0-9.-]", "_") +
                 File.separator +
-                chapter.name.replaceAll("[^a-zA-Z0-9.-]", "_");
+                chapter.name.replaceAll("[^\\sa-zA-Z0-9.-]", "_") + " (" + chapter.id + ")";
 
         return new File(preferences.getDownloadsDirectory(), chapterRelativePath);
     }

+ 3 - 1
app/src/main/java/eu/kanade/mangafeed/data/source/base/Source.java

@@ -105,7 +105,9 @@ public abstract class Source extends BaseSource {
                 .getStringResponse(getBaseUrl() + overrideChapterUrl(chapterUrl), requestHeaders, null)
                 .flatMap(unparsedHtml -> {
                     List<Page> pages = convertToPages(parseHtmlToPageUrls(unparsedHtml));
-                    return Observable.just(parseFirstPage(pages, unparsedHtml));
+                    return !pages.isEmpty() ?
+                            Observable.just(parseFirstPage(pages, unparsedHtml)) :
+                            Observable.error(new Exception("Page list is empty"));
                 });
     }
 

+ 3 - 1
app/src/main/java/eu/kanade/mangafeed/data/source/online/english/Kissmanga.java

@@ -203,7 +203,9 @@ public class Kissmanga extends Source {
                 .flatMap(networkService::mapResponseToString)
                 .flatMap(unparsedHtml -> {
                     List<Page> pages = convertToPages(parseHtmlToPageUrls(unparsedHtml));
-                    return Observable.just(parseFirstPage(pages, unparsedHtml));
+                    return !pages.isEmpty() ?
+                            Observable.just(parseFirstPage(pages, unparsedHtml)) :
+                            Observable.error(new Exception("Page list is empty"));
                 });
     }