diff options
| author | Damien George <damien.p.george@gmail.com> | 2020-05-28 12:50:44 +1000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2020-05-29 23:05:01 +1000 |
| commit | 22806ed5df27c10131af0cedb2f7e8b134fe6e7a (patch) | |
| tree | 0780301c7b5ac2efb2a6759956fc575f23a62230 /extmod/vfs.c | |
| parent | 8f642677f724e725813155f74e5934b8c94fc1c4 (diff) | |
extmod/vfs: Retain previous working directory if chdir fails.
Fixes issue #6069.
Diffstat (limited to 'extmod/vfs.c')
| -rw-r--r-- | extmod/vfs.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/extmod/vfs.c b/extmod/vfs.c index 79a8e8509..d1291068a 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -322,7 +322,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_open_obj, 0, mp_vfs_open); mp_obj_t mp_vfs_chdir(mp_obj_t path_in) { mp_obj_t path_out; mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out); - MP_STATE_VM(vfs_cur) = vfs; if (vfs == MP_VFS_ROOT) { // If we change to the root dir and a VFS is mounted at the root then // we must change that VFS's current dir to the root dir so that any @@ -334,9 +333,11 @@ mp_obj_t mp_vfs_chdir(mp_obj_t path_in) { break; } } + vfs = MP_VFS_ROOT; } else { mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &path_out); } + MP_STATE_VM(vfs_cur) = vfs; return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj, mp_vfs_chdir); |
