Skip to content

(BF, BMD, SPD, PAK) Fix files not being emulated after initial creation#29

Merged
Sewer56 merged 1 commit intoSewer56:mainfrom
AnimatedSwine37:tryadd-fix
Apr 21, 2025
Merged

(BF, BMD, SPD, PAK) Fix files not being emulated after initial creation#29
Sewer56 merged 1 commit intoSewer56:mainfrom
AnimatedSwine37:tryadd-fix

Conversation

@AnimatedSwine37
Copy link
Copy Markdown
Contributor

This fixes a bug that's present in BF, BMD, SPD, and PAK emulators that causes files to not be emulated if they are opened more than once (only the first creation works).

This is due to us using TryAdd in the _pathToEmulated concurrent dictionaries that should be used to pass back the previously emulated file when a file tries to be created subsequent times. It fails if something is already in the dictionary and since we put the value null in to prevent recursion, we end up with null even after emulation succeeds.

For simplicity I've just replaced TryAdd with a direct index (dict[thing]) instead of TryUpdate since I don't think concurrency is really a problem right now. Maybe this is something we need to consider more at some point but I'd guess that's a bigger problem?

@Sewer56
Copy link
Copy Markdown
Owner

Sewer56 commented Apr 21, 2025

Maybe this is something we need to consider more at some point but I'd guess that's a bigger problem?

You're expected to use these APIs during startup in general, so I think it's fine; the chances of concurrency issues there are pretty much for the most part, 0.

@Sewer56 Sewer56 merged commit f94caa5 into Sewer56:main Apr 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants