Fix a warning.
Fix #1031.
Fix crash when trying to import file without read permission (Fix #987).