From: Tom Hughes Date: Wed, 22 Apr 2020 12:34:19 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/2597' X-Git-Tag: live~3233 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/64b3e289ac14533c6fb2b1223b6417ad0446878c?hp=359d76c8f0983d6010a9d45e4481decd4a3e06d9 Merge remote-tracking branch 'upstream/pull/2597' --- diff --git a/app/models/trace.rb b/app/models/trace.rb index d500784af..959d82e1c 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -117,7 +117,7 @@ class Trace < ApplicationRecord end def mime_type - filetype = `/usr/bin/file -Lbz #{trace_name}`.chomp + filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp gzipped = filetype =~ /gzip compressed/ bzipped = filetype =~ /bzip2 compressed/ zipped = filetype =~ /Zip archive/ @@ -139,7 +139,7 @@ class Trace < ApplicationRecord end def extension_name - filetype = `/usr/bin/file -Lbz #{trace_name}`.chomp + filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp gzipped = filetype =~ /gzip compressed/ bzipped = filetype =~ /bzip2 compressed/ zipped = filetype =~ /Zip archive/ @@ -208,8 +208,7 @@ class Trace < ApplicationRecord end def xml_file - # TODO: *nix specific, could do to work on windows... would be functionally inferior though - check for '.gz' - filetype = `/usr/bin/file -Lbz #{trace_name}`.chomp + filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp gzipped = filetype =~ /gzip compressed/ bzipped = filetype =~ /bzip2 compressed/ zipped = filetype =~ /Zip archive/