mindstorm38 / portablemc

A fast, reliable and cross-platform command-line Minecraft launcher and API for developers. Including fast and easy installation of common mod loaders such as Fabric, Forge, NeoForge and Quilt.
https://pypi.org/project/portablemc/
GNU General Public License v3.0
372 stars 20 forks source link

Havein trouble installing a version #220

Closed AinRyzen closed 4 months ago

AinRyzen commented 6 months ago

So to put this in context, I build a GUI app around your module with tkinter or customtkinter, so I have to run the launch process in a thread and I think that's what make this issue I noticed that the version would work after I rebooted my application however here is the error

  File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\standard.py", line 326, in install
    self._download(watcher)
  File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\standard.py", line 967, in _download
    for result_count, result in self._dl.download(threads_count, partial_progress=True):
  File "C:\Users\benno\AppData\Local\Programs\Python\Python312\Lib\site-packages\portablemc\download.py", line 213, in download
    raise ValueError(f"unexpected crash from thread {crash.thread_id}", crash.origin)
ValueError: ('unexpected crash from thread 30', PermissionError(13, 'Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird')) 
mindstorm38 commented 6 months ago

Are you sure that the installation is run only once at a time? It looks like the same file is downloaded twice at the same time

AinRyzen commented 6 months ago

Are you sure that the installation is run only once at a time? It looks like the same file is downloaded twice at the same time

i am defining a Context and a Version than i install it and After that i am running the Version all in a thread when i am home will send you a replica of this situation

mindstorm38 commented 6 months ago

Your report is interesting tho., because it may be an issue with PMC, where the same file is downloaded twice at the same time by different downloading threads.

AinRyzen commented 6 months ago

Your report is interesting tho., because it may be an issue with PMC, where the same file is downloaded twice at the same time by different downloading threads.

Here is my example

import customtkinter as ctk
import threading
import portablemc.standard
import pathlib
def launch():
    def threadlaunch():   context=portablemc.standard.Context(main_dir=pathlib.Path("maintesting"),work_dir=pathlib.Path("maintesting"))
        print("Defining the version")
        version = portablemc.standard.Version(version="1.16.5",context=context)
        print("installing")
        env = version.install()
        print("Running") 
        env.run()
    threading.Thread(target=threadlaunch,daemon=True).start()                       
window = ctk.CTk()
startbutton = ctk.CTkButton(window,text="Start",command=launch)
startbutton.pack(pady=10,padx=10,fill="both")
window.mainloop()

Apparently, this dose only happen when the script is run in a thread

AinRyzen commented 5 months ago

Never mind, I just got this error without using threading

mindstorm38 commented 5 months ago

Ok, this is definitely interesting, would you be ok to take time to test a specific dev branch later on?

mindstorm38 commented 5 months ago

Also, from you "print" calls, are you sure that only one threadlaunch is called at a time? (threaded or not, I don't know if the callback given to CTkButton is launched in a thread.

AinRyzen commented 5 months ago

Also, from you "print" calls, are you sure that only one threadlaunch is called at a time? (threaded or not, I don't know if the callback given to CTkButton is launched in a thread.

Yes i am sure that it's downloading only once i think its a specific file or folder that is a problem you might saw that the main directory and working directory are the same maybe there are two folder or file who have the same name if you know what i mean but that doesn't explain why working without the thread it's definitely installing a few folder and files and only than give me the error

mindstorm38 commented 5 months ago

I'll be working on a new patch version soon, I'll try to fix the issue at the same time.

mindstorm38 commented 5 months ago

I've found the issue, I think. For example, in the asset index 17 there are two identical assets 6ea4e448fbc2a079acb0cf3564273083dadae165: minecraft/sounds/entity/fish/swim1.ogg and minecraft/sounds/liquid/swim1.ogg. I didn't know this was possible, so I'll just download once.

AinRyzen commented 5 months ago

Nice

mindstorm38 commented 4 months ago

Fixed in 4.4.0, reopen the issue if not