Skip to content

Commit eea831c

Browse files
committed
Add update-search-index subcommand to database
1 parent 3cb642a commit eea831c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ cargo run -- start-web-server
9494
# This is the main command to build and add a documentation into docs.rs.
9595
cargo run -- build crate <CRATE_NAME> <CRATE_VERSION>
9696

97+
9798
# Adds essential files (css and fonts) into database to avoid duplication
9899
# This command needs to be run after each rustc update
99100
cargo run -- build add-essential-files
100101

102+
101103
# Builds every crate adds them into database
102104
# (beware: this may take months to finish)
103105
cargo run -- build world
@@ -110,24 +112,35 @@ cargo run -- build world
110112
# Initializes database. Currently, only creates tables in database.
111113
cargo run -- database init
112114

115+
113116
# Adds a directory into database to serve with `staticfile` crate.
114117
cargo run -- database add-directory <DIRECTORY> [PREFIX]
115118

119+
116120
# Updates github stats for crates.
117121
# You need to set CRATESFYI_GITHUB_USERNAME, CRATESFYI_GITHUB_ACCESSTOKEN
118122
# environment variables in order to run this command.
119123
# You can define them in ~/.cratesfyi.env file.
120124
cargo run -- database update-github-fields
121125

122-
# Updates release activitiy
126+
127+
# Updates search-index.
128+
# daemon is running this command occasionally, and this command must be
129+
# run to update recent-version of a crate and search index.
130+
# If you are having any trouble with accessing right version of a crate,
131+
# run this command.
132+
cargo run -- database update-search-index
133+
134+
135+
# Updates release activitiy chart
123136
cargo run -- database update-release-activity
124137
```
125138

126139

127140
#### `doc` subcommand
128141

129142
This subcommand will only build documentation of a crate.
130-
This subcommand is designed to run inside a container.
143+
It is designed to run inside a secure container.
131144

132145
```
133146
cargo run -- doc <CRATE_NAME>

src/bin/cratesfyi.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern crate time;
99

1010

1111
use std::env;
12-
use std::process;
1312
use std::path::PathBuf;
1413

1514
use clap::{Arg, App, SubCommand};
@@ -199,20 +198,15 @@ pub fn main() {
199198

200199
} else if let Some(matches) = matches.subcommand_matches("database") {
201200
if let Some(_) = matches.subcommand_matches("init") {
202-
use std::io::Write;
203-
use std::io;
204201
let conn = db::connect_db().unwrap();
205-
if let Err(err) = db::create_tables(&conn) {
206-
writeln!(&mut io::stderr(), "Failed to initialize database: {}", err).unwrap();
207-
process::exit(1);
208-
}
202+
db::create_tables(&conn).expect("Failed to initialize database");
209203
} else if let Some(_) = matches.subcommand_matches("update-github-fields") {
210204
cratesfyi::utils::github_updater().expect("Failed to update github fields");
211205
} else if let Some(matches) = matches.subcommand_matches("add-directory") {
212206
add_path_into_database(&db::connect_db().unwrap(),
213207
matches.value_of("PREFIX").unwrap_or(""),
214208
matches.value_of("DIRECTORY").unwrap())
215-
.unwrap();
209+
.expect("Failed to add directory into database");
216210
} else if let Some(_) = matches.subcommand_matches("update-release-activity") {
217211
// FIXME: This is actually util command not database
218212
cratesfyi::utils::update_release_activity().expect("Failed to update release activity");

0 commit comments

Comments
 (0)