jobobby04/TachiyomiSY

Backup Manga To Local Source

Opened this issue · 0 comments

Describe your suggested feature

The whole idea behind this prevent the loss of access to manga because it's source/page is now gone.
and While the app does cache lost sources, there can many a case where a source will after a manga has completed pay wall 90% of the chapters, which when the manga gets to that state those downloaded chapters no longer show up even if the ui shows the count for example one of mine says "300|5|EN" but when i open it only 5 chapters show up.

The Following is a poor man's implementation of this by replacing the shareManga method for testing as i could not figure out how to add more items to the menu myself.
It's here simply as a jumping off point, and better explanation of the feature in question.

Other details

@RequiresApi(Build.VERSION_CODES.O)
    private fun shareManga(context: Context, manga: Manga?, source: Source?) {
        if (manga==null) {return}
        val localSourceFileSystem: LocalSourceFileSystem = Injekt.get()
        val downloadManager: DownloadManager = Injekt.get()
        val sourceDir = downloadManager.getMangaFolder(manga)
        val localBaseDir = localSourceFileSystem.getBaseDirectory()
        if (localBaseDir == null) return
        //val comicInfo: ComicInfo =manga.toSManga().getComicInfo()
        //val comicdatafile = XML.encodeToString(ComicInfo.serializer(), comicInfo).byteInputStream()
        try {
            val localMangaDir = localBaseDir.createDirectory(sourceDir.name)!!
            //Files.copy(comicdatafile, Path("${localMangaDir.filePath}/$COMIC_INFO_FILE"), StandardCopyOption.REPLACE_EXISTING)
            Log.i("MangaScreen", "source dir: ${sourceDir.filePath}, output dir: ${localBaseDir.filePath}")
            sourceDir.listFiles()?.forEach {
                Files.copy(Path(it.filePath!!), Path(localBaseDir.filePath!!+"/${sourceDir.name}/${it.name}"), StandardCopyOption.REPLACE_EXISTING)
            }
            context.toast("Copy Complete Check Local Source")
        } catch (e: IOException) {
            Log.e("MangaScreen", "sendToLocal", e)
        }
    }

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open or closed issue.
  • I have written a short but informative title.
  • I have updated the app to version 1.10.5.
  • I will fill out all of the requested information in this form.