@@ -451,19 +451,19 @@ def find_preferences_txt(runtime_ide_path):
451451 # Windows 8 and up option will save "preferences.txt" in one location.
452452 # The downloaded Windows 7 (and up version) will put "preferences.txt"
453453 # in a different location. When both are present due to various possible
454- # scenarios, use the more modern .
454+ # scenarios, give preference to the APP store .
455455 fqfn = os .path .expanduser ("~\Documents\ArduinoData\preferences.txt" )
456456 # Path for "Windows app" - verified on Windows 10 with Arduino IDE 1.8.19 from APP store
457- fqfn2 = os .path .expanduser ( "~\AppData\local \Arduino15\preferences.txt" )
457+ fqfn2 = os .path .normpath ( os . getenv ( "LOCALAPPDATA" ) + " \Arduino15\preferences.txt" )
458458 # Path for Windows 7 and up - verified on Windows 10 with Arduino IDE 1.8.19
459459 if os .path .exists (fqfn ):
460460 if os .path .exists (fqfn2 ):
461461 print_err ("Multiple 'preferences.txt' files found:" )
462462 print_err (" " + fqfn )
463463 print_err (" " + fqfn2 )
464- return [fqfn , None ]
465- else :
466464 return [fqfn , fqfn2 ]
465+ else :
466+ return [fqfn , None ]
467467 elif os .path .exists (fqfn2 ):
468468 return [fqfn2 , None ]
469469 elif "Darwin" == platform_name :
@@ -529,16 +529,19 @@ def check_preferences_txt(runtime_ide_path, preferences_file):
529529
530530def touch (fname , times = None ):
531531 with open (fname , "ab" ) as file :
532- os .utime (file .fileno (), times )
532+ file .close ();
533+ os .utime (fname , times )
533534
534535def synchronous_touch (globals_h_fqfn , commonhfile_fqfn ):
535536 global debug_enabled
536537 # touch both files with the same timestamp
537538 touch (globals_h_fqfn )
538539 with open (globals_h_fqfn , "rb" ) as file :
539- ts = os .stat (file .fileno ())
540- with open (commonhfile_fqfn , "ab" ) as file2 :
541- os .utime (file2 .fileno (), ns = (ts .st_atime_ns , ts .st_mtime_ns ))
540+ file .close ()
541+ with open (commonhfile_fqfn , "ab" ) as file2 :
542+ file2 .close ()
543+ ts = os .stat (globals_h_fqfn )
544+ os .utime (commonhfile_fqfn , ns = (ts .st_atime_ns , ts .st_mtime_ns ))
542545
543546 if debug_enabled :
544547 print_dbg ("After synchronous_touch" )
0 commit comments