Skip to content

Commit 8253c50

Browse files
committed
Add default target to database
1 parent 7e36f87 commit 8253c50

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/db/add_package.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
use ChrootBuilderResult;
3+
use Metadata;
34
use utils::source_path;
45
use regex::Regex;
56

@@ -40,6 +41,7 @@ pub fn add_package_into_database(conn: &Connection,
4041
&TargetKind::Lib(_) => true,
4142
_ => false,
4243
};
44+
let metadata = Metadata::from_package(pkg);
4345

4446
let release_id: i32 = {
4547
let rows = try!(conn.query("SELECT id FROM releases WHERE crate_id = $1 AND version = $2",
@@ -53,11 +55,11 @@ pub fn add_package_into_database(conn: &Connection,
5355
homepage_url, description, description_long, readme,
5456
authors, keywords, have_examples, downloads, files,
5557
doc_targets, is_library, doc_rustc_version,
56-
documentation_url
58+
documentation_url, default_target
5759
)
5860
VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10,
5961
$11, $12, $13, $14, $15, $16, $17, $18, $19,
60-
$20, $21, $22, $23, $24
62+
$20, $21, $22, $23, $24, $25
6163
)
6264
RETURNING id",
6365
&[&crate_id,
@@ -83,7 +85,8 @@ pub fn add_package_into_database(conn: &Connection,
8385
&doc_targets.to_json(),
8486
&is_library,
8587
&res.rustc_version,
86-
&pkg.manifest().metadata().documentation]));
88+
&pkg.manifest().metadata().documentation,
89+
&metadata.default_target]));
8790
// return id
8891
rows.get(0).get(0)
8992

@@ -110,7 +113,8 @@ pub fn add_package_into_database(conn: &Connection,
110113
doc_targets = $21,
111114
is_library = $22,
112115
doc_rustc_version = $23,
113-
documentation_url = $24
116+
documentation_url = $24,
117+
default_target = $25
114118
WHERE crate_id = $1 AND version = $2",
115119
&[&crate_id,
116120
&format!("{}", pkg.manifest().version()),
@@ -135,7 +139,8 @@ pub fn add_package_into_database(conn: &Connection,
135139
&doc_targets.to_json(),
136140
&is_library,
137141
&res.rustc_version,
138-
&pkg.manifest().metadata().documentation]));
142+
&pkg.manifest().metadata().documentation,
143+
&metadata.default_target]));
139144
rows.get(0).get(0)
140145
}
141146
};

src/db/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub fn create_tables(conn: &Connection) -> Result<(), Error> {
112112
files JSON,
113113
doc_targets JSON DEFAULT '[]',
114114
doc_rustc_version VARCHAR(100) NOT NULL,
115+
default_target VARCHAR(100),
115116
UNIQUE (crate_id, version)
116117
)",
117118
"CREATE TABLE authors (

0 commit comments

Comments
 (0)