Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mimetypealiases.json to mimetypealiases.dist.json #17509

Merged
merged 1 commit into from
Jul 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions config/mimetypealiases.json → config/mimetypealiases.dist.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"_comment" : "When this file is changed make sure to run",
"_comment2": "./occ maintenance:mimetypesjs",
"_comment3": "Otherwise your update won't propagate through the system",
"_comment" : "Array of mimetype aliases.",
"_comment2": "Any changes you make here will be overwritten on an update of ownCloud.",
"_comment3": "Put any custom aliases in a new file mimetypealiases.json in this directory",

"_comment4": "After any change to mimetypealiases.json run:",
"_comment5": "./occ maintenance:mimetypesjs",
"_comment6": "Otherwise your update won't propagate through the system.",


"application/coreldraw": "image",
Expand Down
7 changes: 6 additions & 1 deletion core/command/maintenance/mimetypesjs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
// Fetch all the aliases
$aliases = json_decode(file_get_contents(dirname(__DIR__) . '/../../config/mimetypealiases.json'), true);
$aliases = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mimetypealiases.dist.json'), true);

if (file_exists(\OC::$SERVERROOT . '/config/mimetypealiases.json')) {
$custom = get_object_vars(json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mimetypealiases.json')));
$aliases = array_merge($aliases, $custom);
}

// Remove comments
$keys = array_filter(array_keys($aliases), function($k) {
Expand Down
7 changes: 6 additions & 1 deletion lib/private/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,13 @@ public static function mimetypeIcon($mimetype) {

// On first access load the list of mimetype aliases
if (empty(self::$mimeTypeAlias)) {
$file = file_get_contents(OC::$SERVERROOT . '/config/mimetypealiases.json');
$file = file_get_contents(OC::$SERVERROOT . '/config/mimetypealiases.dist.json');
self::$mimeTypeAlias = get_object_vars(json_decode($file));

if (file_exists(\OC::$SERVERROOT . '/config/mimetypealiases.json')) {
$custom = get_object_vars(json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mimetypealiases.json')));
self::$mimeTypeAlias = array_merge(self::$mimeTypeAlias, $custom);
}
}

if (isset(self::$mimeTypeAlias[$mimetype])) {
Expand Down