You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that there is no nice way to get rid of a RawFile handle if for example the SD card is ejected, since calls to crate::VolumeManager::close_file will result in a returned error before the file id is removed from the open_files list.
In my testing, I have implemented the following:
if volume_mgr.write(file, data.as_slice()).is_err(){
volume_mgr.destroy_file(file).unwrap();
volume_mgr.close_dir(dir).unwrap();
volume_mgr.close_volume(volume).unwrap();continue'setup;// Loop back and retry connecting to card}
where
/// Destroy a file for the given RawFile, without updating its entry./// This can be useful if the SD card is suddenly ejected, and one must/// notify the VolumeManager that we are dropping the handle.pubfndestroy_file(&mutself,file:RawFile) -> Result<(),Error<D::Error>>{let file_idx = self.get_file_by_id(file)?;self.open_files.swap_remove(file_idx);Ok(())}
Which works nicely. Another option would be to modify the close_file method to first get the index, remove from the list, and then try to update the entry by flusing (as implemented in #121):
/// Close a file with the given full path.pubfnclose_file(&mutself,file:RawFile) -> Result<(),Error<D::Error>>{let file_idx = self.get_file_by_id(file)?;self.open_files.swap_remove(file_idx);self.flush(file)?;Ok(())}
The text was updated successfully, but these errors were encountered:
It seems that there is no nice way to get rid of a RawFile handle if for example the SD card is ejected, since calls to
crate::VolumeManager::close_file
will result in a returned error before the file id is removed from theopen_files
list.In my testing, I have implemented the following:
where
Which works nicely. Another option would be to modify the
close_file
method to first get the index, remove from the list, and then try to update the entry by flusing (as implemented in #121):The text was updated successfully, but these errors were encountered: