From 3fc72da9ae13748b0444a9048393a0012579b01c Mon Sep 17 00:00:00 2001 From: Andre LeBlanc Date: Thu, 25 Feb 2021 19:57:45 -0500 Subject: [PATCH] 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 --- klippy/extras/virtual_sdcard.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py index 699add31..8d192c54 100644 --- a/klippy/extras/virtual_sdcard.py +++ b/klippy/extras/virtual_sdcard.py @@ -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)