Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace single config.json with a buffer of files #1

Closed

Conversation

mikeseese
Copy link
Contributor

This makes it so that we never have to rename a config.json.bak file over the current config.json file. This also reduces the chance of file writing collusion. This is to prevent corrupt config.json files

See nylas-mail-lives/nylas-mail#15 and nylas/nylas-mail#3382

This makes it so that we never have to rename a config.json.bak file over the current config.json file. This also reduces the chance of file writing collusion. This is to prevent corrupt config.json files

const files = getSortedTimestampedFilesSync(filepath, basename, extension);

while (files.length > 10) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this hardcoded 10 is the number of config.timestamp.json files to keep. we may want to put this in a variable instead of inline hardcode. we may also might want this to be configurable? /shrug

I figured 10 would be enough when I wrote this; I haven't ran into a case when all 10 are corrupt

@mikeseese
Copy link
Contributor Author

Is this waiting on anything @bengotow?

@mikeseese
Copy link
Contributor Author

FYI nylas-mail-lives/nylas-mail#134 and nylas-mail-lives/nylas-mail#141 are further implementations on top of this PR

@bengotow
Copy link
Collaborator

Hey! Awesome thanks—I haven't merged this yet because if it's possible, I'd rather figure out why the config.json file is becoming corrupt in the first place and fix that. (Doing an atomic write + replace should be safe, especially now that all the writes are done from the main process and not from each window separately.) So far there haven't been any reports of corrupt config.json files in the Mailspring fork, though it might just be that Account objects aren't changed nearly as often since sync happens outside the app.

@mikeseese
Copy link
Contributor Author

I'm fairly certain it's due to several applications are making changes several times a minute to the same file. My best guess is you won't see this problem due to the different sync process. I'm going to close this PR for now

@mikeseese mikeseese closed this Oct 30, 2017
bengotow added a commit that referenced this pull request Nov 7, 2017
@jeffrussell37 jeffrussell37 mentioned this pull request Mar 12, 2020
@foundry376-bot
Copy link

This pull request has been mentioned on Mailspring Community. There might be relevant details there:

https://community.getmailspring.com/t/mailspring-shows-wrong-subject/640/1

mamantoha pushed a commit to mamantoha/Mailspring that referenced this pull request Nov 29, 2021
@bengotow bengotow mentioned this pull request Dec 1, 2021
CutestNekoAqua pushed a commit to CutestNekoAqua/Mailbase that referenced this pull request Oct 6, 2023
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.

None yet

3 participants