Closed WDoughty closed 5 months ago
Hello. I will try to have a look at this PR in the foreseeable future. Thank you for the PR. It looks good from a quick glance.
Unfortunately Directory.CreateSymbolicLink
is not an exact replacement for the current process.
Currently, Stardrop creates a junction while this PR creates a symbolic link. There are a few differences between the two, but the primary benefit of using a junction is that it does not require administrative privileges when using Windows. If you are using Linux / MacOS, I do not believe that it requires such (I have not tested this).
An example of the error:
[Debug][MainWindow.UpdateEnabledModsFolder: Line 2266] Failed to link all mod folders: System.IO.IOException: A required privilege is not held by the client. : 'C:\Users\Floogen\AppData\Roaming\Stardrop\Data\Selected Mods\AlternativeTextures' at Interop.Kernel32.CreateSymbolicLink(String symlinkFileName, String targetFileName, Boolean isDirectory) at System.IO.Directory.CreateSymbolicLink(String path, String pathToTarget) at Stardrop.Views.MainWindow.<>c.
b__98_0(ModToLinkPath modToLinkPath) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2276 at System.Collections.Generic.List 1.ForEach(Action
1 action) at Stardrop.Views.MainWindow.CreateSymlinkDirectories(List`1 modToLinkPaths) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2274 at Stardrop.Views.MainWindow.UpdateEnabledModsFolder(Profile profile, String enabledModsPath) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2260
Is there no way arround admin rights for a faster linking? Also is there a specific reson for using appdata folder here? It forces me to give SD admin rights because rly no app/software is allowed on my machin to write in this trash can folder because it only does wasting space on my C: drive and this also increases r/w operations which could simply eliminated by compleatly eliminating this behavior and instead storing all mods in the main SD Folder, then copy them into the created profile folders and then do one symlink from the profil to the mods folder. This would allow per profile configs which are only changing when updating the mod, otherwise you could have a mod in "n" different profiles but also with "n" different edits. Sure there are some 300MB+ mods but hey, who has today not at last 1TB SSD/NVMe storage installed?
So I would suggest to a per profile-mod-copy rather then the usage of unnessecary appdata folder - which needs definitly to be eliminated and get rid of - like MultiMC is doing it with different profiling where you can choos the storage path for each MC instance.
Unfortunately
Directory.CreateSymbolicLink
is not an exact replacement for the current process.Currently, Stardrop creates a junction while this PR creates a symbolic link. There are a few differences between the two, but the primary benefit of using a junction is that it does not require administrative privileges when using Windows. If you are using Linux / MacOS, I do not believe that it requires such (I have not tested this).
An example of the error:
[Debug][MainWindow.UpdateEnabledModsFolder: Line 2266] Failed to link all mod folders: System.IO.IOException: A required privilege is not held by the client. : 'C:\Users\Floogen\AppData\Roaming\Stardrop\Data\Selected Mods\AlternativeTextures' at Interop.Kernel32.CreateSymbolicLink(String symlinkFileName, String targetFileName, Boolean isDirectory) at System.IO.Directory.CreateSymbolicLink(String path, String pathToTarget) at Stardrop.Views.MainWindow.<>c.b__98_0(ModToLinkPath modToLinkPath) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2276 at System.Collections.Generic.List
1.ForEach(Action
1 action) at Stardrop.Views.MainWindow.CreateSymlinkDirectories(List`1 modToLinkPaths) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2274 at Stardrop.Views.MainWindow.UpdateEnabledModsFolder(Profile profile, String enabledModsPath) in C:\Users\Floogen\Documents\GitHub Repos\Stardrop\Stardrop\Views\MainWindow.axaml.cs:line 2260
That's odd because I don't get any errors when running on Windows 11, but that may be up to my environment. Also a little weird that Microsoft doesn't have a junction link in the default library where something like node does include junctions. I'll do some more investigation when I have some more time.
This changes creating symbolic links from the outside process to creating them via the api. This should reduce the time it takes to create the symbolic links.
Testing loading in 80 mods
Before:
![image](https://github.com/Floogen/Stardrop/assets/72272567/4b9a69ca-3ba5-420d-a652-b0c15462f526)
After:
![image](https://github.com/Floogen/Stardrop/assets/72272567/eb9c90e5-ed7c-4cb9-87a9-eee5931e3e48)