mirror of
https://github.com/discourse/discourse.git
synced 2025-04-22 13:39:08 +08:00

Currently we allow for 2 theme screenshots to be specified, with a lightweight spec to allow both a light and dark version of the screenshot. However, we were not storing this screenshot name anywhere, so we would not be able to use it for light/dark switching. This commit fixes that issue, and also does some general refactoring around theme screenshots, and adds more tests.
46 lines
984 B
Ruby
46 lines
984 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rubygems/package"
|
|
|
|
module Compression
|
|
class Tar < Strategy
|
|
def extension
|
|
".tar"
|
|
end
|
|
|
|
def compress(path, target_name)
|
|
tar_filename = FileHelper.sanitize_filename("#{target_name}.tar")
|
|
Discourse::Utils.execute_command(
|
|
"tar",
|
|
"--create",
|
|
"--file",
|
|
tar_filename,
|
|
target_name,
|
|
failure_message: "Failed to tar file.",
|
|
)
|
|
|
|
sanitize_path("#{path}/#{tar_filename}")
|
|
end
|
|
|
|
private
|
|
|
|
def extract_folder(_entry, _entry_path)
|
|
end
|
|
|
|
def get_compressed_file_stream(compressed_file_path)
|
|
file_stream = IO.new(IO.sysopen(compressed_file_path))
|
|
tar_extract = Gem::Package::TarReader.new(file_stream)
|
|
tar_extract.rewind
|
|
yield(tar_extract)
|
|
end
|
|
|
|
def build_entry_path(dest_path, entry, _)
|
|
File.join(dest_path, entry.full_name)
|
|
end
|
|
|
|
def decompression_results_path(dest_path, _)
|
|
dest_path
|
|
end
|
|
end
|
|
end
|