-
Notifications
You must be signed in to change notification settings - Fork 212
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
Decouples Cache and Download behaviour #493
Conversation
25b7426
to
a772871
Compare
0942de6
to
9e5fa6e
Compare
9e5fa6e
to
df9c8c1
Compare
return provider(mangaId, chapterId).delete() | ||
} | ||
|
||
fun putImage(mangaId: Int, chapterId: Int, index: Int, image: InputStream): Boolean { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
server/src/main/kotlin/suwayomi/tachidesk/manga/impl/ChapterDownloadHelper.kt
Outdated
Show resolved
Hide resolved
server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadedFilesProvider.kt
Outdated
Show resolved
Hide resolved
server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/FolderProvider.kt
Outdated
Show resolved
Hide resolved
server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/FolderProvider.kt
Outdated
Show resolved
Hide resolved
@Syer10 made the changes you've requested till now |
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:
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.FileProvider
as the default provider implementingDownloadedFilesProvider
that implements the default behaviour of saving each page as a separate image in the chapter folder inside downloads directory.ChapterDownloadHelper
object that works as aDownloadedFilesProvider
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.