Skip to content

Conversation

SuuperW
Copy link
Contributor

@SuuperW SuuperW commented Jul 13, 2025

Also make movies write to a temporary file first, writing the entire file before touching the old one.

Addresses #4258.

Check if completed:

Copy link
Member

@YoshiRulz YoshiRulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better I/O handling has been sorely needed for a while. I suspect the .tasproj corruptions will end with this.

@@ -1,3 +1,5 @@
#nullable enable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check the whole file for null-correctness?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With so much code changes I knew I'd forget something. Checking it now, compiler incorrectly infers string? for var backupName yet doesn't complain about passing potentially null to Path.GetFileName for some reason. There's also a ! null-suppression operator in Directory.CreateDirectory(Path.GetDirectoryName(fn)!); which would be an issue if the user selected a file in the root directory but that's not one I put there. And there's a ? that should be added later.

Aside from that, it is of course touching properties of the movie that don't use nullable but it looks like it is handling them correctly.

@SuuperW SuuperW force-pushed the dot_saving branch 2 times, most recently from fde3481 to 0798074 Compare July 14, 2025 07:42
@SuuperW
Copy link
Contributor Author

SuuperW commented Jul 14, 2025

Highlights of force push:

  1. Added constraint to FileWriteResult and .editorconfig rules to enforce compliance.
  2. Re-did some closing and disposing stuff and order of things to make it work in all situations that I could think to test. Including a new "Abort" mechanism.

@SuuperW
Copy link
Contributor Author

SuuperW commented Jul 14, 2025

Well I just re-read the linked issue and realized that this PR does nothing to address that. I had seen BizHawk and autosave and assumed it meant TAStudio auto-saving because I forget that there is another autosave. Handling of sram saving failure will come later.

@SuuperW SuuperW marked this pull request as draft July 14, 2025 19:11
SuuperW added 9 commits July 19, 2025 19:06
…e until writing has completed. Avoids crashing and prevents loss of data in the event of an exception mid-write.
… sram data length, because it already wasn't true for all cores. Cores that require a specific size should throw if they get the wrong size.
…celing flow even though not all asking and error handling is implemented yet. Also, fix: respect the cancel button.
@SuuperW SuuperW changed the title Handle exceptions while writing a movie file Handle exceptions while writing to files Jul 22, 2025
@SuuperW
Copy link
Contributor Author

SuuperW commented Jul 22, 2025

Now handles errors for SRAM, config file, savestates, and all tools' AskSaveChanges (and related save menu items).
Some file writes have not been updated. Are there any others that should be done? TAStudio macros probably should be, I guess.

@SuuperW SuuperW marked this pull request as ready for review July 22, 2025 08:12
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