efreet: check magic only for file which has size

Summary:
Due to unnecessary magic checking, there was freezing in /proc in efm.
Proc file's st_size is zero, but, it's readable. therfore, it takes unnecessary time in magic checking. And, there is no need to check magic in case of 0 sized regular files as well.

Therefore, skip magic check in case of st_size is zero.

Fixes T1173

Test Plan: enlightenment -> file browser (efm) -> get int /proc --> check whether efm freezes or not

Reviewers: raster, cedric, zmike

CC: seoz, cedric

Maniphest Tasks: T1173

Differential Revision: https://phab.enlightenment.org/D764

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
This commit is contained in:
Wonguk Jeong 2014-04-17 19:34:33 +02:00 committed by Cedric Bail
parent d9ea423b91
commit e32f033853
1 changed files with 8 additions and 0 deletions

View File

@ -1244,6 +1244,14 @@ efreet_mime_magic_check_priority(const char *file,
const char *last_mime = NULL;
int c;
char v, buf[EFREET_MIME_MAGIC_BUFFER_SIZE];
struct stat s;
#ifdef _WIN32
if (stat(file, &s) || s.st_size == 0)
#else
if (lstat(file, &s) || s.st_size == 0)
#endif
return NULL;
f = fopen(file, "rb");
if (!f) return NULL;