Skip to content

Commit

Permalink
Fix the urlencoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Aug 12, 2023
1 parent 3afe287 commit f4393b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/models/podcast_episode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::models::podcasts::Podcast;
use crate::utils::do_retry::do_retry;
use crate::utils::time::opt_or_empty_string;
use diesel::AsChangeset;
use crate::service::podcast_episode_service::PodcastEpisodeService;
use crate::utils::error::{CustomError, map_db_error};

#[derive(Queryable, Identifiable,QueryableByName, Selectable, Debug, PartialEq, Clone, ToSchema,
Expand Down Expand Up @@ -226,9 +227,8 @@ impl PodcastEpisode{
diesel::update(podcast_episodes)
.filter(episode_id_column.eq(episode_id))
.set((
local_image_url_column.eq(image_url),
local_url_column.eq(local_download_url),
))
local_image_url_column.eq(PodcastEpisodeService::map_to_local_url(image_url)),
local_url_column.eq(PodcastEpisodeService::map_to_local_url(local_download_url))))
.execute(conn)
.expect("Error updating local image url");
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/service/podcast_episode_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ impl PodcastEpisodeService {
.map(|podcast| {
let mut podcast_episode_dto = self.mapping_service.map_podcastepisode_to_dto(podcast);
if podcast_episode_dto.is_downloaded() {
let local_url = self.map_to_local_url(&podcast_episode_dto.clone().local_url);
let local_image_url = self.map_to_local_url(&podcast_episode_dto.clone()
let local_url = Self::map_to_local_url(&podcast_episode_dto.clone().local_url);
let local_image_url = Self::map_to_local_url(&podcast_episode_dto.clone()
.local_image_url);

podcast_episode_dto.local_image_url = env.server_url.clone() + &local_image_url;
Expand All @@ -382,7 +382,7 @@ impl PodcastEpisodeService {
}


fn map_to_local_url(&mut self, url: &str) -> String {
pub fn map_to_local_url(url: &str) -> String {
let splitted_url = url.split('/').collect::<Vec<&str>>();
splitted_url.iter()
.map(|s| return if s.starts_with("podcasts.") || s.starts_with("image.") {
Expand Down

0 comments on commit f4393b6

Please sign in to comment.