mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Apply syntax_tree formatting to lib/*
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'zip'
|
||||
require "zip"
|
||||
|
||||
module Compression
|
||||
class Zip < Strategy
|
||||
def extension
|
||||
'.zip'
|
||||
".zip"
|
||||
end
|
||||
|
||||
def compress(path, target_name)
|
||||
@ -15,7 +15,7 @@ module Compression
|
||||
::Zip::File.open(zip_filename, ::Zip::File::CREATE) do |zipfile|
|
||||
if File.directory?(absolute_path)
|
||||
entries = Dir.entries(absolute_path) - %w[. ..]
|
||||
write_entries(entries, absolute_path, '', zipfile)
|
||||
write_entries(entries, absolute_path, "", zipfile)
|
||||
else
|
||||
put_into_archive(absolute_path, zipfile, target_name)
|
||||
end
|
||||
@ -47,15 +47,14 @@ module Compression
|
||||
remaining_size = available_size
|
||||
|
||||
if ::File.exist?(entry_path)
|
||||
raise ::Zip::DestinationFileExistsError,
|
||||
"Destination '#{entry_path}' already exists"
|
||||
raise ::Zip::DestinationFileExistsError, "Destination '#{entry_path}' already exists"
|
||||
end
|
||||
|
||||
::File.open(entry_path, 'wb') do |os|
|
||||
::File.open(entry_path, "wb") do |os|
|
||||
entry.get_input_stream do |is|
|
||||
entry.set_extra_attributes_on_path(entry_path)
|
||||
|
||||
buf = ''.dup
|
||||
buf = "".dup
|
||||
while (buf = is.sysread(chunk_size, buf))
|
||||
remaining_size -= chunk_size
|
||||
raise ExtractFailed if remaining_size.negative?
|
||||
@ -70,7 +69,7 @@ module Compression
|
||||
# A helper method to make the recursion work.
|
||||
def write_entries(entries, base_path, path, zipfile)
|
||||
entries.each do |e|
|
||||
zipfile_path = path == '' ? e : File.join(path, e)
|
||||
zipfile_path = path == "" ? e : File.join(path, e)
|
||||
disk_file_path = File.join(base_path, zipfile_path)
|
||||
|
||||
if File.directory? disk_file_path
|
||||
|
Reference in New Issue
Block a user