Skip to content

Commit 51ef1db

Browse files
committed
Fix incorrect relative path to the cache
1 parent cfbd3a1 commit 51ef1db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/jekyll/transcode-image-filters.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def _compute_cache_filename(absolute_path_source, resolution, format)
4040
# * [String] absolute_path_cache - Full path to the cache directory
4141
# * [String] file_name_destination - Name of the destination file
4242
# * [String] relative_path_destination - Relative path to the destination file
43+
# * [String] relative_path_cache - Relative path to the cache directory
4344
def _compute_paths(absolute_path_site, relative_path_source, relative_cache_dir, resolution, format)
4445
absolute_path_source = File.join(absolute_path_site, relative_path_source)
4546
raise "No file found at #{absolute_path_source}" unless File.readable?(absolute_path_source)
@@ -48,11 +49,12 @@ def _compute_paths(absolute_path_site, relative_path_source, relative_cache_dir,
4849
file_name_source_sanitized = _sanitize_name(file_name_source)
4950
file_name_destination = _compute_cache_filename(absolute_path_source, resolution, format)
5051

52+
relative_path_cache = File.join(relative_cache_dir, file_name_source_sanitized)
5153
absolute_path_cache = File.join(absolute_path_site, relative_cache_dir, file_name_source_sanitized)
5254
absolute_path_destination = File.join(absolute_path_cache, file_name_destination)
5355
relative_path_destination = File.join(relative_cache_dir, file_name_source_sanitized, file_name_destination)
5456

55-
[absolute_path_source, absolute_path_destination, absolute_path_cache, file_name_destination, relative_path_destination]
57+
[absolute_path_source, absolute_path_destination, absolute_path_cache, file_name_destination, relative_path_destination, relative_path_cache]
5658
end
5759

5860
# Determine whether the file exists in the cache.
@@ -94,7 +96,7 @@ def _process_img(absolute_path_source, absolute_path_destination, resolution, fo
9496
def _transcode_image (relative_source_path, cache_dir, resolution, format)
9597
site = @context.registers[:site]
9698

97-
absolute_path_source, absolute_path_destination, absolute_path_cache, file_name_destination, relative_path_destination = _compute_paths(site.source, relative_source_path, cache_dir, resolution, format)
99+
absolute_path_source, absolute_path_destination, absolute_path_cache, file_name_destination, relative_path_destination, relative_path_cache = _compute_paths(site.source, relative_source_path, cache_dir, resolution, format)
98100

99101
# Guarantee the existence of the cache directory
100102
FileUtils.mkdir_p(absolute_path_cache)
@@ -106,7 +108,7 @@ def _transcode_image (relative_source_path, cache_dir, resolution, format)
106108
# otherwise, we process the file and add it to the cache
107109

108110
_process_img(absolute_path_source, absolute_path_destination , resolution, format)
109-
site.static_files << Jekyll::StaticFile.new(site, site.source, cache_dir, file_name_destination)
111+
site.static_files << Jekyll::StaticFile.new(site, site.source, relative_path_cache, file_name_destination)
110112
end
111113

112114
relative_path_destination

0 commit comments

Comments
 (0)