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

Added support for image cache downloading without image Feature #460

Merged
merged 5 commits into from
Jun 2, 2024

Conversation

jStimpert0430
Copy link
Contributor

@jStimpert0430 jStimpert0430 commented Jun 1, 2024

Resolves #458

Image cache download is now solely based upon the enable_cover_image_cache option regardless if the image feature is used or not.

…es enable_cover_image_cache app.toml option instead
Comment on lines 1384 to 1400
if configs.app_config.enable_cover_image_cache{
if !state.data.read().caches.images.contains_key(url) {
let bytes = self
.retrieve_image(url, &path, configs.app_config.enable_cover_image_cache)
.await?;
let image =
image::load_from_memory(&bytes).context("Failed to load image from memory")?;
state
.data
.write()
.caches
.images
.insert(url.to_owned(), image, *TTL_CACHE_DURATION);
}
}


#[cfg(any(feature = "image", feature = "notify"))]
Copy link
Owner

@aome510 aome510 Jun 2, 2024

Choose a reason for hiding this comment

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

you can keep MemoryCaches and image feature optional by updating the logic to retrieve and save image separately if the image cache is enabled

Suggested change
if configs.app_config.enable_cover_image_cache{
if !state.data.read().caches.images.contains_key(url) {
let bytes = self
.retrieve_image(url, &path, configs.app_config.enable_cover_image_cache)
.await?;
let image =
image::load_from_memory(&bytes).context("Failed to load image from memory")?;
state
.data
.write()
.caches
.images
.insert(url.to_owned(), image, *TTL_CACHE_DURATION);
}
}
#[cfg(any(feature = "image", feature = "notify"))]
if configs.app_config.enable_cover_image_cache{
self
.retrieve_image(url, &path, true)
.await?;
}
#[cfg(feature = "image")]
if !state.data.read().caches.images.contains_key(url) {
let bytes = self
.retrieve_image(url, &path, false)
.await?;
let image =
image::load_from_memory(&bytes).context("Failed to load image from memory")?;
state
.data
.write()
.caches
.images
.insert(url.to_owned(), image, *TTL_CACHE_DURATION);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yeah, that makes sense; I don't know why I was trying to avoid adding that extra code block. I'll add those checks back in and recommit. Thanks!

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 the suggested changes and removed the loose Feature check since it was no longer needed.

Copy link
Owner

Choose a reason for hiding this comment

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

can you undo the change in Cargo.toml as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh whoops, absolutely. Re-pushed.

Copy link
Owner

@aome510 aome510 left a comment

Choose a reason for hiding this comment

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

Thanks for the change. I did some extra cleanup myself, which is also relevant to this PR

@aome510 aome510 merged commit b180b6b into aome510:master Jun 2, 2024
3 checks passed
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.

support saving cover images without image feature
2 participants