mirror of
https://github.com/TeamPiped/sponsorblock-mirror.git
synced 2024-08-14 23:57:05 +00:00
Fix database VACCUMing.
This commit is contained in:
parent
886dc76bf4
commit
3618088cf8
1 changed files with 7 additions and 2 deletions
|
@ -72,12 +72,17 @@ fn rocket() -> Rocket<Build> {
|
|||
println!("Importing database...");
|
||||
// Execute a query of some kind
|
||||
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() {
|
||||
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;
|
||||
println!("Imported database in {}ms", start.elapsed().as_millis());
|
||||
|
||||
unsafe {
|
||||
LAST_UPDATE = Some(last_modified);
|
||||
|
|
Loading…
Reference in a new issue