NathanVaughn / msfs-mod-manager

An external mod manager for the new Microsoft Flight Simulator
GNU General Public License v3.0
98 stars 4 forks source link

Trouble with certain mod #44

Closed Jimver closed 3 years ago

Jimver commented 3 years ago

Hello, upon installing the following livery from flightsim.to: https://flightsim.to/file/3209/united-nations-cessna-208-b I get an error upon installation (see image below, could not copy the text unfortunately).

It's quite strange as the layout.json seems fine to me.

Expected Behavior

Mod installs successfully without errors

Actual Behavior

Error given on install: afbeelding

Steps to Reproduce the Problem

  1. Download mod at: https://flightsim.to/file/3209/united-nations-cessna-208-b
  2. Install it via the tool
  3. Get error

Specifications

Debug Log Contents (only if reporting a bug)

This file is found at %APPDATA%\MSFS Mod Manager\debug.log

(Everything after the last __main__:<module>:27 - ----------------------- line)

2020-11-13 15:16:39.571 | DEBUG    | lib.flight_sim:__init__:50 - Initialzing mod archive installer thread
2020-11-13 15:16:39.574 | DEBUG    | lib.thread:run:21 - Running thread
2020-11-13 15:16:39.589 | DEBUG    | lib.flight_sim:install_mod_archive:497 - Installing mod C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip
2020-11-13 15:16:39.590 | DEBUG    | lib.flight_sim:extract_mod_archive:432 - Extracting archive C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip
2020-11-13 15:16:39.595 | DEBUG    | lib.files:delete_folder:143 - Attempting to delete folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager
2020-11-13 15:16:39.605 | DEBUG    | lib.files:create_tmp_folder:241 - Creating temp folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager
2020-11-13 15:16:39.606 | DEBUG    | lib.files:extract_archive:284 - Extracting archive C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip to C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-13 15:16:39.842 | DEBUG    | lib.flight_sim:install_mods:472 - Installing mod C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-13 15:16:39.843 | DEBUG    | lib.flight_sim:determine_mod_folders:446 - Locating mod folders inside C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-13 15:16:39.845 | DEBUG    | lib.flight_sim:determine_mod_folders:461 - Mod found C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-13 15:16:39.853 | DEBUG    | lib.files:move_folder:198 - Moving folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN to C:\Users\Jim\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-13 15:16:39.853 | DEBUG    | lib.files:copy_folder:166 - Copying folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN to C:\Users\Jim\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-13 15:16:39.856 | DEBUG    | lib.files:delete_folder:143 - Attempting to delete folder C:\Users\Jim\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-13 15:16:39.880 | DEBUG    | lib.files:get_folder_size:100 - Returning size of C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN recursively
2020-11-13 15:16:40.104 | DEBUG    | lib.thread:run:27 - Thread completed
2020-11-13 15:16:40.105 | ERROR    | widgets.main_widget:base_fail:200 - Failed to install mod archive
2020-11-13 15:16:40.105 | ERROR    | widgets.main_widget:base_fail:201 - <class 'shutil.Error'>: [('C:\\Users\\Jim\\AppData\\Local\\Temp\\MSFS Mod Manager\\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS', 'C:\\Users\\Jim\\AppData\\Local\\Packages\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\LocalCache\\Packages\\Community\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS', "[Errno 2] No such file or directory: 'C:\\\\Users\\\\Jim\\\\AppData\\\\Local\\\\Packages\\\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\\\LocalCache\\\\Packages\\\\Community\\\\Asobo_208B_GRAND_CARAVAN_EX_UN\\\\SimObjects\\\\Airplanes\\\\Asobo_208B_GRAND_CARAVAN_EX-UN\\\\TEXTURE.UN\\\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS'"), ('C:\\Users\\Jim\\AppData\\Local\\Temp\\MSFS Mod Manager\\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json', 'C:\\Users\\Jim\\AppData\\Local\\Packages\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\LocalCache\\Packages\\Community\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json', "[Errno 2] No such file or directory: 'C:\\\\Users\\\\Jim\\\\AppData\\\\Local\\\\Packages\\\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\\\LocalCache\\\\Packages\\\\Community\\\\Asobo_208B_GRAND_CARAVAN_EX_UN\\\\SimObjects\\\\Airplanes\\\\Asobo_208B_GRAND_CARAVAN_EX-UN\\\\TEXTURE.UN\\\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json'")]
2020-11-13 15:16:41.400 | DEBUG    | lib.flight_sim:get_enabled_mods:383 - Retrieving list of enabled mods
NathanVaughn commented 3 years ago

I've actually seen this error myself. This is caused by a race condition in the files.delete_folder function. This could be one of two causes:

  1. A bug with the CPython interpreter with shutil.rmtree as outlined in this issue: https://bugs.python.org/issue29699
  2. My own fault, where if os.path.isdir(folder) checks if the folder exists before deleting it, but it no longer exists by the time shutil.rmtree tries to delete it, as described more here: https://github.com/mopidy/mopidy/issues/1766

Now, the easy solution is to just set ignore_errors=True, but I still want some errors being raised so I can attempt to fix directory permissions: https://blog.nathanv.me/posts/python-permission-issue/

Anyways, I think I've developed a fix, but I have not gotten a chance yet to fully test it and push it to a release.

NathanVaughn commented 3 years ago

I was unable to get the issue to occur on my machine to test my fix, but I think it should work. I've pushed version 0.5.2 which incorporates this. I'm going to close the issue for now, but if it comes up still, please just re-open it.

Jimver commented 3 years ago

I still get the issue unfortunately this is in v0.5.3, btw I cannot reopen the issue it seems:

afbeelding

2020-11-15 15:21:12.241 | DEBUG    | lib.flight_sim:install_mod_archive:521 - Installing mod C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip
2020-11-15 15:21:12.241 | DEBUG    | lib.files:hash_file:349 - Hashing C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip
2020-11-15 15:21:12.243 | DEBUG    | lib.files:read_hash:374 - No hash found
2020-11-15 15:21:12.244 | DEBUG    | lib.flight_sim:extract_mod_archive:451 - Hash mismatch, extracting
2020-11-15 15:21:12.244 | DEBUG    | lib.files:delete_folder:151 - Attempting to delete folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager
2020-11-15 15:21:12.246 | DEBUG    | lib.files:create_tmp_folder:254 - Creating temp folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager
2020-11-15 15:21:12.246 | DEBUG    | lib.files:extract_archive:297 - Extracting archive C:/Users/Jim/Downloads/Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL.zip to C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-15 15:21:12.498 | DEBUG    | lib.flight_sim:install_mods:493 - Installing mod C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-15 15:21:12.498 | DEBUG    | lib.flight_sim:determine_mod_folders:467 - Locating mod folders inside C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL
2020-11-15 15:21:12.501 | DEBUG    | lib.flight_sim:determine_mod_folders:482 - Mod found C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-15 15:21:12.505 | DEBUG    | lib.files:copy_folder:179 - Copying folder C:\Users\Jim\AppData\Local\Temp\MSFS Mod Manager\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\Asobo_208B_GRAND_CARAVAN_EX_UN to C:\Users\Jim\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community\Asobo_208B_GRAND_CARAVAN_EX_UN
2020-11-15 15:21:12.508 | DEBUG    | lib.files:delete_folder:147 - Folder C:\Users\Jim\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community\Asobo_208B_GRAND_CARAVAN_EX_UN does not exist
2020-11-15 15:21:12.662 | DEBUG    | lib.thread:run:28 - Thread completed
2020-11-15 15:21:12.663 | ERROR    | widgets.main_widget:base_fail:209 - Failed to install mod archive
2020-11-15 15:21:12.663 | ERROR    | widgets.main_widget:base_fail:210 - <class 'shutil.Error'>: [('C:\\Users\\Jim\\AppData\\Local\\Temp\\MSFS Mod Manager\\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS', 'C:\\Users\\Jim\\AppData\\Local\\Packages\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\LocalCache\\Packages\\Community\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS', "[Errno 2] No such file or directory: 'C:\\\\Users\\\\Jim\\\\AppData\\\\Local\\\\Packages\\\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\\\LocalCache\\\\Packages\\\\Community\\\\Asobo_208B_GRAND_CARAVAN_EX_UN\\\\SimObjects\\\\Airplanes\\\\Asobo_208B_GRAND_CARAVAN_EX-UN\\\\TEXTURE.UN\\\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_DECAL_ALBD.PNG.DDS.FLAGS'"), ('C:\\Users\\Jim\\AppData\\Local\\Temp\\MSFS Mod Manager\\Asobo_208B_GRAND_CARAVAN_EX_UN_YtQmL\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json', 'C:\\Users\\Jim\\AppData\\Local\\Packages\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\LocalCache\\Packages\\Community\\Asobo_208B_GRAND_CARAVAN_EX_UN\\SimObjects\\Airplanes\\Asobo_208B_GRAND_CARAVAN_EX-UN\\TEXTURE.UN\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json', "[Errno 2] No such file or directory: 'C:\\\\Users\\\\Jim\\\\AppData\\\\Local\\\\Packages\\\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\\\LocalCache\\\\Packages\\\\Community\\\\Asobo_208B_GRAND_CARAVAN_EX_UN\\\\SimObjects\\\\Airplanes\\\\Asobo_208B_GRAND_CARAVAN_EX-UN\\\\TEXTURE.UN\\\\CESSNA_208B_GRANDCARAVANEX_AIRFRAME_LIVERY_ALBD.PNG.DDS.json'")]
NathanVaughn commented 3 years ago

Just wanted to say, haven't forgotten about this issue. I just graduated from college and am finishing up moving. Hopefully I'll be able to address this next week.

NathanVaughn commented 3 years ago

Note for myself: This issue only occurs when compiled with PyInstaller, not when running on the interpreter directly. I think this may have to do with the path of the file being deleted being too long for DOS (260 characters).

NathanVaughn commented 3 years ago

I know I've said this before, but I think I finally figured it out and fixed it.

I'm fairly certain now that it wasn't some sort of race condition, but in fact that the Windows path to the file was too long (old-school DOS legacy stuff imposes a limit of something like 260 characters), causing the cryptic FileNotFoundError even though the file existed (especially with the Liveries Megapack stuff with some huge filenames) I think I've fixed it by prepending \\?\ to all file copy/move/delete operations. See this for more info: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces

What also made this difficult to track down, is that it doesn't happen when I run the application locally with my installed Python interpreter, only when run after being packaged with PyInstaller.

NathanVaughn commented 3 years ago

Should be fixed for real in f904414 and Version 0.5.5. Feel free to re-open if it recoccurs.