Skip to content

Commit

Permalink
add update-rust-project script
Browse files Browse the repository at this point in the history
  • Loading branch information
arvid220u committed Jul 11, 2022
1 parent e55275d commit 214ed0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion daemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
Set up VSCode rust-analyzer (very recommended!):

```
bazelisk run @rules_rust//tools/rust_analyzer:gen_rust_project
./update-rust-project.sh
```

Then restart the rust-analyzer server in VSCode with F1 and then searching for "Rust analyzer: restart server".

## Database changes

We want to create a migration!
Expand Down
7 changes: 6 additions & 1 deletion daemon/db/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,12 @@ unsafe fn errmsg_to_string(errmsg: *const std::os::raw::c_char) -> String {
impl DB {
pub fn connect(&self) -> Result<SqliteConnection, DbError> {
match SqliteConnection::establish(&self.address) {
Ok(c) => Ok(c),
Ok(c) => {
// we sleep for up to 1000 ms while the database is locked
// we also enforce foreign key constraints
c.batch_execute("PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 1000;")?;
Ok(c)
},
Err(e) => return Err(DbError::Unknown(format!("failed to connect to database, {}", e,))),
}
}
Expand Down
10 changes: 10 additions & 0 deletions daemon/update-rust-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

if [[ $(sd --version || true) != *"sd"* ]]; then
echo "Installing sd..."
cargo install sd
fi

sd rust_static_library rust_library "${ANYSPHEREROOT}"/client/daemon/BUILD
bazelisk run @rules_rust//tools/rust_analyzer:gen_rust_project
sd rust_library rust_static_library "${ANYSPHEREROOT}"/client/daemon/BUILD

0 comments on commit 214ed0a

Please sign in to comment.