mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
core/modtrezorio: raise exception when directory listing fails on disk error or other error
This commit is contained in:
parent
24359ea074
commit
59ee3750d1
@ -272,7 +272,11 @@ STATIC mp_obj_t mod_trezorio_FatFSDir_iternext(mp_obj_t self) {
|
|||||||
mp_obj_FatFSDir_t *o = MP_OBJ_TO_PTR(self);
|
mp_obj_FatFSDir_t *o = MP_OBJ_TO_PTR(self);
|
||||||
FILINFO info;
|
FILINFO info;
|
||||||
FRESULT res = f_readdir(&(o->dp), &info);
|
FRESULT res = f_readdir(&(o->dp), &info);
|
||||||
if (res != FR_OK || info.fname[0] == 0) { // stop on error or end of dir
|
if (res != FR_OK) {
|
||||||
|
f_closedir(&(o->dp));
|
||||||
|
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||||
|
}
|
||||||
|
if (info.fname[0] == 0) { // stop on end of dir
|
||||||
f_closedir(&(o->dp));
|
f_closedir(&(o->dp));
|
||||||
return MP_OBJ_STOP_ITERATION;
|
return MP_OBJ_STOP_ITERATION;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user