How to replace a running .pck file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamemap

My program should do a self-update, but I can’t replace the .pck file.
I tried HTTPRequest.download_file, Directory. replace and Directory.rename and renaming it just before quitting.

It already worked with the HTTP request, but I don’t know why. (I think it might be because of the file size).

Unfortunately it doesn’t work now.

I hope someone has an idea.

:bust_in_silhouette: Reply From: Calinou

On Windows, you won’t be able to replace the EXE and PCK file while the project is running due to Windows’ file locking limitations. However, you should be able to move those files to %TEMP% where these files can be cleaned automatically by the Disk Cleaner program when the user runs low on disk space.

You can get the path to Windows’ temporary data folder using OS.get_environment("TEMP").

PS: Implementing self-update is a complex process with security implications (such as ensuring the use of secure connections and signing releases). Consider using Steam or itch.io to handle this instead, rather than implementing your own self-update solution which may contain security holes.