Fixed unnecessary detach_all() when config file isn't read (#221)

* Translate code commends into English, removing redundant ones

* - Translated all remaining Japanese code comments in src/raspberrypi/ to English, with the exception of cfilesystem.cpp|h
- Removed some redundant comments where the context is obvious from the
  code
  - Fixed a few typos and mistakes

* - Store only file path and name to configuration csv
- Strip known non-file path strings when reading configuration csv (backwards compatibility)
- Validate SCSI ID before attempting to attach a device

* Add comment and TODO

* Partial translation of cfilesystem.h

* Move csv read/write logic into file_cmd.py

* Load default.csv on rascsi-web startup

* Add rudimentary error handling to config loading/saving

* Implement a delete configuration csv file feature. Also rename the delete_image method to delete_file and made it take the full file patch as argument to be consistent with other file operation methods.

* Catch the exception when attempting to exclude SCSI id that is already in use from a list of valid SCSI ids

* Fix error handling when failing to open a csv file for read or write

* Run detach_all() only after succeeding to open a file for reading
This commit is contained in:
Daniel Markstedt 2021-08-30 11:56:40 -07:00 committed by GitHub
parent 6c5fae6304
commit 45e10480f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,11 +106,11 @@ def write_config_csv(file_name):
return False
def read_config_csv(file_name):
detach_all()
import csv
try:
with open(file_name) as csv_file:
detach_all()
config_reader = csv.reader(csv_file)
#TODO: Remove hard-coded string sanitation (e.g. after implementing protobuf)
exclude_list = ("X68000 HOST BRIDGE", "DaynaPort SCSI/Link", " (WRITEPROTECT)", "NO MEDIA")