mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 05:26:22 +00:00
fix: mejorar gestión de zip
This commit is contained in:
parent
1059ab5501
commit
51e11d38e4
1 changed files with 42 additions and 11 deletions
|
@ -14,24 +14,43 @@ class DeployZip < Deploy
|
||||||
# y generar un zip accesible públicamente.
|
# y generar un zip accesible públicamente.
|
||||||
#
|
#
|
||||||
# rubocop:disable Metrics/MethodLength
|
# rubocop:disable Metrics/MethodLength
|
||||||
def deploy
|
def deploy(output: false)
|
||||||
FileUtils.rm_f path
|
FileUtils.rm_f path
|
||||||
|
|
||||||
time_start
|
time_start
|
||||||
Dir.chdir(destination) do
|
Zip::File.open(path, Zip::File::CREATE) do |zip|
|
||||||
Zip::File.open(path, Zip::File::CREATE) do |z|
|
Dir.glob(File.join(destination, '**', '**')).each do |file|
|
||||||
Dir.glob('./**/**').each do |f|
|
entry = Pathname.new(file).relative_path_from(destination).to_s
|
||||||
File.directory?(f) ? z.mkdir(f) : z.add(f, f)
|
|
||||||
|
if File.directory? file
|
||||||
|
log "Creando directorio #{entry}", output
|
||||||
|
|
||||||
|
zip.mkdir(entry)
|
||||||
|
else
|
||||||
|
log "Comprimiendo #{entry}", output
|
||||||
|
zip.add(entry, file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
time_stop
|
time_stop
|
||||||
|
|
||||||
build_stats.create action: 'zip',
|
File.exist?(path).tap do |status|
|
||||||
seconds: time_spent_in_seconds,
|
build_stats.create action: 'zip',
|
||||||
bytes: size
|
seconds: time_spent_in_seconds,
|
||||||
|
bytes: size,
|
||||||
|
log: @log.join("\n"),
|
||||||
|
status: status
|
||||||
|
end
|
||||||
|
rescue Zip::Error => e
|
||||||
|
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||||
|
|
||||||
File.exist? path
|
build_stats.create action: 'zip',
|
||||||
|
seconds: 0,
|
||||||
|
bytes: 0,
|
||||||
|
log: @log.join("\n"),
|
||||||
|
status: false
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
@ -43,8 +62,9 @@ class DeployZip < Deploy
|
||||||
File.size path
|
File.size path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [String]
|
||||||
def destination
|
def destination
|
||||||
File.join(Rails.root, '_deploy', site.hostname)
|
Rails.root.join('_deploy', site.hostname).realpath.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def file
|
def file
|
||||||
|
@ -58,4 +78,15 @@ class DeployZip < Deploy
|
||||||
def path
|
def path
|
||||||
File.join(destination, file)
|
File.join(destination, file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# @param :line [String]
|
||||||
|
# @param :output [Boolean]
|
||||||
|
def log(line, output)
|
||||||
|
@log ||= []
|
||||||
|
@log << line
|
||||||
|
|
||||||
|
puts line if output
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue