A lot :)
This commit is contained in:
parent
aad67af0d1
commit
63fc206c27
153 changed files with 2043 additions and 646 deletions
|
|
@ -1,10 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class Backup
|
||||
class << self
|
||||
def zip
|
||||
create_records_xlsx
|
||||
|
||||
ZipFileGenerator.new(Rails.root.join('storage')).write
|
||||
ZipFileGenerator.new(Rails.root.join("storage")).write
|
||||
end
|
||||
|
||||
def db_xlsx
|
||||
|
|
@ -21,7 +23,7 @@ module Admin
|
|||
end
|
||||
end
|
||||
end
|
||||
path = Rails.root.join('storage/data.xls')
|
||||
path = Rails.root.join("storage/data.xls")
|
||||
xlsx.serialize(path)
|
||||
path
|
||||
end
|
||||
|
|
@ -29,7 +31,7 @@ module Admin
|
|||
private
|
||||
|
||||
def file_path(name)
|
||||
Rails.root.join('storage', name)
|
||||
Rails.root.join("storage", name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -53,9 +55,9 @@ module Admin
|
|||
# Zip the input directory.
|
||||
def write
|
||||
entries = Dir.entries(@input_dir) - %w[. ..]
|
||||
path = Rails.root.join('tmp', Time.now.to_i.to_s)
|
||||
path = Rails.root.join("tmp", Time.now.to_i.to_s)
|
||||
::Zip::File.open(path, create: true) do |zipfile|
|
||||
write_entries entries, '', zipfile
|
||||
write_entries entries, "", zipfile
|
||||
end
|
||||
path
|
||||
end
|
||||
|
|
@ -65,7 +67,7 @@ module Admin
|
|||
# A helper method to make the recursion work.
|
||||
def write_entries(entries, 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(@input_dir, zipfile_path)
|
||||
|
||||
if File.directory? disk_file_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue