mirror of
https://github.com/TeamPiped/sponsorblock-mirror.git
synced 2024-12-13 22:00:35 +05:30
Fix database VACCUMing.
This commit is contained in:
parent
886dc76bf4
commit
3618088cf8
@ -72,12 +72,17 @@ fn rocket() -> Rocket<Build> {
|
|||||||
println!("Importing database...");
|
println!("Importing database...");
|
||||||
// Execute a query of some kind
|
// Execute a query of some kind
|
||||||
db.run(move |c| {
|
db.run(move |c| {
|
||||||
let result = c.batch_execute("BEGIN; DROP TABLE IF EXISTS \"sponsorTimesTemp\"; CREATE UNLOGGED TABLE \"sponsorTimesTemp\"(LIKE \"sponsorTimes\" INCLUDING defaults INCLUDING constraints INCLUDING indexes); COPY \"sponsorTimesTemp\" FROM '/mirror/sponsorTimes.csv' DELIMITER ',' CSV HEADER; DROP TABLE \"sponsorTimes\"; ALTER TABLE \"sponsorTimesTemp\" RENAME TO \"sponsorTimes\"; COMMIT; VACUUM \"sponsorTimes\";");
|
let result = c.batch_execute("BEGIN; DROP TABLE IF EXISTS \"sponsorTimesTemp\"; CREATE UNLOGGED TABLE \"sponsorTimesTemp\"(LIKE \"sponsorTimes\" INCLUDING defaults INCLUDING constraints INCLUDING indexes); COPY \"sponsorTimesTemp\" FROM '/mirror/sponsorTimes.csv' DELIMITER ',' CSV HEADER; DROP TABLE \"sponsorTimes\"; ALTER TABLE \"sponsorTimesTemp\" RENAME TO \"sponsorTimes\"; COMMIT;");
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
eprintln!("Failed to import database: {}", result.err().unwrap());
|
eprintln!("Failed to import database: {}", result.err().unwrap());
|
||||||
}
|
}
|
||||||
|
println!("Imported database in {}ms", start.elapsed().as_millis());
|
||||||
|
// Vacuum the database
|
||||||
|
let result = c.batch_execute("VACUUM \"sponsorTimes\";");
|
||||||
|
if result.is_err() {
|
||||||
|
eprintln!("Failed to vacuum database: {}", result.err().unwrap());
|
||||||
|
}
|
||||||
}).await;
|
}).await;
|
||||||
println!("Imported database in {}ms", start.elapsed().as_millis());
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
LAST_UPDATE = Some(last_modified);
|
LAST_UPDATE = Some(last_modified);
|
||||||
|
Loading…
Reference in New Issue
Block a user