aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/virtual_sdcard.py
diff options
context:
space:
mode:
authorAndre LeBlanc <andrepleblanc@gmail.com>2021-02-25 19:57:45 -0500
committerKevinOConnor <kevin@koconnor.net>2021-02-26 22:53:35 -0500
commit3fc72da9ae13748b0444a9048393a0012579b01c (patch)
treebac081a4ecc4842e4f20564b5fa65c7ab1464440 /klippy/extras/virtual_sdcard.py
parentc5a9d7914ba0437069306217a6f653975427ba7b (diff)
downloadkutter-3fc72da9ae13748b0444a9048393a0012579b01c.tar.gz
kutter-3fc72da9ae13748b0444a9048393a0012579b01c.tar.xz
kutter-3fc72da9ae13748b0444a9048393a0012579b01c.zip
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>
Diffstat (limited to 'klippy/extras/virtual_sdcard.py')
-rw-r--r--klippy/extras/virtual_sdcard.py4
1 files changed, 3 insertions, 1 deletions
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)