indexing done
This commit is contained in:
parent
5ce5f97924
commit
d8581e6048
1 changed files with 25 additions and 2 deletions
27
src/main.rs
27
src/main.rs
|
|
@ -176,8 +176,31 @@ fn index(db: Connection, path: &String) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dbg!(hash, name, destination, downloaded, uploaded, announce, comment, created_by, creation_date, publisher, publisher_url);
|
// create torrent record
|
||||||
dbg!(files);
|
let id = db.query_row("INSERT INTO torrent (
|
||||||
|
hash, name, destination,
|
||||||
|
downloaded, uploaded,
|
||||||
|
announce, comment,
|
||||||
|
created_by, creation_date,
|
||||||
|
publisher, publisher_url)
|
||||||
|
VALUES (?,?,?,?,?,?,?,?,?,?,?)
|
||||||
|
RETURNING id;", (
|
||||||
|
hash, name, destination,
|
||||||
|
downloaded, uploaded,
|
||||||
|
announce, comment,
|
||||||
|
created_by, creation_date,
|
||||||
|
publisher, publisher_url
|
||||||
|
),
|
||||||
|
|row| Ok(row.get::<usize, i64>(0)?)
|
||||||
|
).expect("insert failed");
|
||||||
|
// we're using here unwrap/expect since we want full program crash
|
||||||
|
// to debug any sql bugs
|
||||||
|
|
||||||
|
// insert torrent files
|
||||||
|
for file in files {
|
||||||
|
db.execute("INSERT INTO file (torrent_id,file_name) VALUES (?,?);", (id, file))
|
||||||
|
.expect("failed to insert file!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue