virtual_sdcard: exact filename match before case insensitive one

currently, if there are 2 files on the virtual sd card whose names differ only in
case (eg. MyFile.gcode vs myfile.gcode) the actual file that gets loaded is at
best unpredictable.  this patch checks for an exact match before attempting a
case-insensitive one.

Signed-off-by: Andre LeBlanc <andrepleblanc@gmail.com>
This commit is contained in:
Andre LeBlanc 2021-02-25 19:57:45 -05:00 committed by KevinOConnor
parent c5a9d7914b
commit 3fc72da9ae
1 changed files with 3 additions and 1 deletions

View File

@ -147,8 +147,10 @@ class VirtualSD:
def _load_file(self, gcmd, filename, check_subdirs=False):
files = self.get_file_list(check_subdirs)
files_by_lower = { fname.lower(): fname for fname, fsize in files }
fname = filename
try:
fname = files_by_lower[filename.lower()]
if fname not in files:
fname = files_by_lower[fname.lower()]
fname = os.path.join(self.sdcard_dirname, fname)
f = open(fname, 'rb')
f.seek(0, os.SEEK_END)