unpack_strategy/zip: ensure consistent timezone management

This commit is contained in:
Bo Anderson 2021-04-27 20:27:00 +01:00
parent 94ce3236a5
commit 7ee76b85d5
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 44 additions and 40 deletions

View File

@ -15,6 +15,7 @@ module UnpackStrategy
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) } sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
def extract_to_dir(unpack_dir, basename:, verbose:) def extract_to_dir(unpack_dir, basename:, verbose:)
with_env(TZ: "UTC") do
if merge_xattrs && contains_extended_attributes?(path) if merge_xattrs && contains_extended_attributes?(path)
# We use ditto directly, because dot_clean has issues if the __MACOSX # We use ditto directly, because dot_clean has issues if the __MACOSX
# folder has incorrect permissions. # folder has incorrect permissions.
@ -59,6 +60,7 @@ module UnpackStrategy
end end
end end
end end
end
private private

View File

@ -27,6 +27,7 @@ module UnpackStrategy
.returns(SystemCommand::Result) .returns(SystemCommand::Result)
} }
def extract_to_dir(unpack_dir, basename:, verbose:) def extract_to_dir(unpack_dir, basename:, verbose:)
with_env(TZ: "UTC") do
quiet_flags = verbose ? [] : ["-qq"] quiet_flags = verbose ? [] : ["-qq"]
result = system_command! "unzip", result = system_command! "unzip",
args: [*quiet_flags, "-o", path, "-d", unpack_dir], args: [*quiet_flags, "-o", path, "-d", unpack_dir],
@ -38,6 +39,7 @@ module UnpackStrategy
result result
end end
end end
end
end end
require "extend/os/mac/unpack_strategy/zip" if OS.mac? require "extend/os/mac/unpack_strategy/zip" if OS.mac?