Skip to content

119 error on dump with no db#533

Merged
smoelius merged 3 commits intomasterfrom
119-error-on-dump-with-no-db
Jun 28, 2023
Merged

119 error on dump with no db#533
smoelius merged 3 commits intomasterfrom
119-error-on-dump-with-no-db

Conversation

@tarunbhm
Copy link
Copy Markdown
Contributor

@tarunbhm tarunbhm commented Jun 27, 2023

Refactor the dump, reset, resume flag, and database existence validation logic. It now does the following:

  1. Exits with an error on using the --dump flag when the database does not exist
  2. Shows warning when running with the --resume or --reset flag, and the database does not exist
  3. Exits with an error when no flag is given but the database exists (this is not new in this PR, it's already there)

closes #119

Reading on the trycmd tests to create one for this PR

@tarunbhm tarunbhm requested a review from smoelius as a code owner June 27, 2023 07:43
@tarunbhm tarunbhm linked an issue Jun 27, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@smoelius smoelius left a comment

Choose a reason for hiding this comment

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

My comments are all very nit-picky. I think the logic looks really solid.

Comment thread core/src/core.rs
Comment thread core/src/sqlite.rs
Comment thread core/src/sqlite.rs Outdated

if must_not_exist && exists {
bail!(
let nodb_msg = |flag: &str| {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let nodb_msg = |flag: &str| {
let no_db_msg = |flag: &str| {

Comment thread core/src/sqlite.rs Outdated
bail!(
let nodb_msg = |flag: &str| {
format!(
"No sqlite database found at {:?} to {}; creating new database",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"No sqlite database found at {:?} to {}; creating new database",
"No sqlite database to {} at {:?}; creating new database",

I think putting the operation first will make it more noticeable.

Comment thread core/src/sqlite.rs Outdated
);
),
(false, true, _, _) => bail!(
"No sqlite database found at {:?}; please remove the --dump flag",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"No sqlite database found at {:?}; please remove the --dump flag",
"--dump was passed, but no sqlite database was found at {:?}",

This is pretty nitpicky, but "remove the --dump flag" sounds like it's going to solve the user's problems, when they probably have bigger problems.

@smoelius
Copy link
Copy Markdown
Collaborator

Actually, one other nice-to-have would be trycmd tests to exercise the new behavior, similar to these:

But that could be a separate PR.

@smoelius smoelius merged commit 020cb1b into master Jun 28, 2023
@smoelius smoelius deleted the 119-error-on-dump-with-no-db branch June 28, 2023 10:28
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.

Should error when --dump is passed and no necessist.db is found

2 participants