Skip to content

Commit a28e79c

Browse files
committed
Add an env var setting for whether we are a mirror or not
By default, we are not a mirror.
1 parent 13e12d5 commit a28e79c

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# `postgres://postgres:@localhost/cargo_registry`.
44
export DATABASE_URL=""
55

6+
# If you are running a mirror of crates.io, uncomment this line.
7+
# export MIRROR=1
8+
69
# Key to sign and encrypt cookies with. Change this to a long, random string
710
# for production.
811
export SESSION_KEY="badkey"

src/bin/fill-in-user-id.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn main() {
3333
db_url: env("DATABASE_URL"),
3434
env: cargo_registry::Env::Production,
3535
max_upload_size: 0,
36+
mirror: false,
3637
};
3738
let app = cargo_registry::App::new(&config);
3839
{

src/bin/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn main() {
5757
db_url: env("DATABASE_URL"),
5858
env: cargo_env,
5959
max_upload_size: 10 * 1024 * 1024,
60+
mirror: env::var("MIRROR").is_ok(),
6061
};
6162
let app = cargo_registry::App::new(&config);
6263
let app = cargo_registry::middleware(Arc::new(app));

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Config {
1414
pub db_url: String,
1515
pub env: ::Env,
1616
pub max_upload_size: u64,
17+
pub mirror: bool,
1718
}
1819

1920
impl Config {

src/tests/all.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fn app() -> (record::Bomb, Arc<App>, conduit_middleware::MiddlewareBuilder) {
9090
db_url: env("TEST_DATABASE_URL"),
9191
env: cargo_registry::Env::Test,
9292
max_upload_size: 1000,
93+
mirror: false,
9394
};
9495
INIT.call_once(|| db_setup(&config.db_url));
9596
let app = App::new(&config);

0 commit comments

Comments
 (0)