X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a7092491b069de43bb8d8c30d3526e7095c5cc98..64b3e289ac14533c6fb2b1223b6417ad0446878c:/app/models/trace.rb diff --git a/app/models/trace.rb b/app/models/trace.rb index f1cd72acd..959d82e1c 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -25,7 +25,7 @@ # gpx_files_user_id_fkey (user_id => users.id) # -class Trace < ActiveRecord::Base +class Trace < ApplicationRecord self.table_name = "gpx_files" belongs_to :user, :counter_cache => true @@ -117,7 +117,7 @@ class Trace < ActiveRecord::Base 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 < ActiveRecord::Base 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 < ActiveRecord::Base 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/