Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouples Cache and Download behaviour #493

Merged
merged 7 commits into from
Feb 12, 2023

Conversation

akabhirav
Copy link
Contributor

@akabhirav akabhirav commented Feb 9, 2023

Decoupling Cache and Download behaviour

Separating cache directory from Download directory

Tachidesk's caching and download logic are tightly coupled. This includes the cache directory being the same as download directory. Ideally the directory for files meant to be temporarily stored as cache should be the operating system's temp directory. The first change deals with changing the cache directory to the OS' temp directory

Implementing a new Downloader logic

Now that cached files are stored in another place, the downloader relying on cache logic to store the page(image) files no longer works. To fix this we need to make the downloader self-reliant which only asks the ImageRespone to be in image and then stores the file to the download folder on it's own

Technicals

All of this introduces a few new changes in the server:

  1. Introduced DownloadedFilesProvider as an abstract class which sets up the struture for a provider that is responsible for handling downloaded files i.e. getting, putting and deleting pages.
  2. Introduced FileProvider as the default provider implementing DownloadedFilesProvider that implements the default behaviour of saving each page as a separate image in the chapter folder inside downloads directory.
  3. Introduced ChapterDownloadHelper object that works as a DownloadedFilesProvider factory which generates the appropriate provider object. This abstracts the complexity that each provider must implement to store it's own logic for the above mentioned tasks.

@akabhirav akabhirav force-pushed the cache-download-improvements branch 2 times, most recently from 25b7426 to a772871 Compare February 9, 2023 12:36
@akabhirav akabhirav force-pushed the cache-download-improvements branch 2 times, most recently from 0942de6 to 9e5fa6e Compare February 9, 2023 14:21
@akabhirav akabhirav changed the title Separate cache dir from download dir Decouples Cache and Download behaviour Feb 9, 2023
return provider(mangaId, chapterId).delete()
}

fun putImage(mangaId: Int, chapterId: Int, index: Int, image: InputStream): Boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to change this to download since we don't need a single put image here, we can just move the entire downlod logic here. Also, building an ArchiveProvider is proving difficult since appending to zip is not working for some reason

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change in the latest commit

@akabhirav
Copy link
Contributor Author

@Syer10 made the changes you've requested till now

@AriaMoradi AriaMoradi merged commit b10062c into Suwayomi:master Feb 12, 2023
@akabhirav akabhirav deleted the cache-download-improvements branch February 24, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants