Added backwards compat override to Dir class

This commit is contained in:
Tristan Ancelet 2024-10-22 14:14:27 -05:00
parent 713ea521c8
commit 696a71bd8b

View File

@ -30,6 +30,15 @@ class Dir
output_path
end
end
## For backwards compat
def chdir(dir = nil &block)
if dir.nil?
Dir.chdir(self, &block)
else
Dir.chdir(dir, &block)
end
end
end
class String
@ -170,7 +179,7 @@ class Installer
file_contents = Net::HTTP.get(uri)
output_file = "discord-#{version}.tar.gz"
puts "download_installer: Output file will #{output_file}"
Dir.chdir($CONFIG[:install_dir]) do
$CONFIG[:install_dir].chdir do
File.open(output_file, 'wb') do |file|
file.write(file_contents)
end
@ -181,7 +190,7 @@ class Installer
def install
installer_file = "discord-#{self.remote_version}.tar.gz"
puts "do_install: Extracting new installer"
Dir.chdir($CONFIG[:install_dir]) do
$CONFIG[:install_dir].chdir do
File.open(installer_file, 'rb') do |file|
Gem::Package.new("").extract_tar_gz(file, $CONFIG[:install_dir])
end
@ -249,7 +258,7 @@ def make_backup
end
Dir.chdir(Dir.home) do
puts "make_backup: Beginning backup process (OUTPUT_FILE = #{Dir.getwd}/#{$CONFIG[:backup_filename]})"
puts "make_backup: Beginning backup process (OUTPUT_FILE = #{Dir.getwd/$CONFIG[:backup_filename]})"
File.open($CONFIG[:backup_filename], "wb") do |backup_file|
Zlib::GzipWriter.wrap(backup_file) do |gzip|
Gem::Package::TarWriter.new(gzip) do |tar|