Compare commits

...

2 Commits

Author SHA1 Message Date
wxiaoguang 0a9a3c2a6d
Improve frontend guideline (#23252)
If an event listener must be `async`, the `e.preventDefault()` should be
before any `await`,
it's recommended to put it at the beginning of the function.
2023-03-02 11:46:47 -05:00
wxiaoguang 294124d129
Close the temp file when dumping database to make the temp file can be deleted on Windows (#23249)
There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.
2023-03-02 23:57:31 +08:00
2 changed files with 4 additions and 0 deletions

View File

@ -272,6 +272,7 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to create tmp file: %v", err)
}
defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
}

View File

@ -83,6 +83,9 @@ It's not recommended to use `async` event listeners, which may lead to problems.
The reason is that the code after await is executed outside the event dispatch.
Reference: https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventdefault.md
If an event listener must be `async`, the `e.preventDefault()` should be before any `await`,
it's recommended to put it at the beginning of the function.
If we want to call an `async` function in a non-async context,
it's recommended to use `const _promise = asyncFoo()` to tell readers
that this is done by purpose, we want to call the async function and ignore the Promise.