Avoid code duplication

Signed-off-by: Michal Čihař <michal@cihar.com>
Sanitize filename in import message

Signed-off-by: Michal Čihař <michal@cihar.com>