Skip to content

Commit a997fe1

Browse files
committed
MOBILE-1984 fs: Remove hash when getting extension
1 parent a207fee commit a997fe1

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

www/core/lib/fs.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,20 @@ angular.module('mm.core')
869869
*/
870870
self.getFileIcon = function(filename) {
871871
var ext = self.getFileExtension(filename),
872-
icon;
872+
icon = 'unknown';
873873

874-
if (ext && extToMime[ext] && extToMime[ext].icon) {
875-
icon = extToMime[ext].icon + '-64.png';
876-
} else {
877-
icon = 'unknown-64.png';
874+
if (ext && extToMime[ext]) {
875+
if (extToMime[ext].icon) {
876+
icon = extToMime[ext].icon;
877+
} else {
878+
var type = extToMime[ext].type.split('/')[0];
879+
if (type == 'video' || type == 'text' || type == 'image' || type == 'document' || type == 'audio') {
880+
icon = type;
881+
}
882+
}
878883
}
879884

880-
return 'img/files/' + icon;
885+
return 'img/files/' + icon + '-64.png';
881886
};
882887

883888
/**
@@ -909,6 +914,10 @@ angular.module('mm.core')
909914

910915
if (dot > -1) {
911916
ext = filename.substr(dot + 1).toLowerCase();
917+
918+
// Remove hash in extension if there's any. @see $mmFilepool#_getFileIdByUrl
919+
ext = ext.replace(/_.{32}$/, '');
920+
912921
// Check extension corresponds to a mimetype to know if it's valid.
913922
if (typeof self.getMimeType(ext) == 'undefined') {
914923
$log.debug('Get file extension: Not valid extension ' + ext);

www/core/lib/ws.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ angular.module('mm.core')
324324
* @return {Promise} The success returns the fileEntry, the reject will contain the error object.
325325
*/
326326
self.downloadFile = function(url, path, addExtension) {
327-
$log.debug('Downloading file ' + url);
327+
$log.debug('Downloading file ' + url, path, addExtension);
328328

329329
// Use a tmp path to download the file and then move it to final location.This is because if the download fails,
330330
// the local file is deleted.

0 commit comments

Comments
 (0)