Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mimemagic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
mimemagic
Commits
86ed210d
Commit
86ed210d
authored
Mar 25, 2021
by
Jon Wood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Iterate on finding a database
parent
9af2d220
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
ext/mimemagic/Rakefile
+16
-16
No files found.
ext/mimemagic/Rakefile
View file @
86ed210d
...
...
@@ -2,22 +2,22 @@ require "rubygems"
require
"rake/clean"
def
locate_mime_database
# User provided path.
unless
ENV
[
"FREEDESKTOP_MIME_TYPES_PATH"
].
nil?
path
=
File
.
expand_path
(
ENV
[
"FREEDESKTOP_MIME_TYPES_PATH"
])
unless
File
.
exist?
(
path
)
raise
"The path
#{
path
}
was provided for the MIME types database, but no file exists at that path.
"
end
return
path
end
# Default path on Linux installs for the MIME types database.
return
"/usr/share/mime/packages/freedesktop.org.xml"
if
File
.
exist?
(
"/usr/share/mime/packages/freedesktop.org.xml"
)
# Default path when installed with Homebrew
return
"/usr/local/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml"
if
File
.
exist?
(
"/usr/local/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml"
)
raise
"No database of MIME types could be found. Ensure you have either installed the shared-mime-types package for your distribution, or obtain a version of freedesktop.org.xml, and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file."
possible_paths
=
[
(
File
.
expand_path
(
ENV
[
"FREEDESKTOP_MIME_TYPES_PATH"
])
if
ENV
[
"FREEDESKTOP_MIME_TYPES_PATH"
]),
"/usr/local/share/mime/packages/freedesktop.org.xml"
,
"/opt/homebrew/share/mime/packages/freedesktop.org.xml"
,
"/usr/share/mime/packages/freedesktop.org.xml
"
].
compact
path
=
possible_paths
.
find
{
|
candidate
|
File
.
exist?
(
candidate
)
}
return
path
unless
path
.
nil?
raise
(
<<~
ERROR
)
Could not find MIME type database in the following locations:
#{
possible_paths
}
Ensure you have either installed the shared-mime-types package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
of that file.
ERROR
end
desc
"Build a file pointing at the database"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment