Skip to content

Commit

Permalink
Switch to not exists and fix path deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
maplant committed May 14, 2024
1 parent 9cc4cc6 commit 7e447ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions mobile_verifier/migrations/33_data_sets.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
CREATE TYPE data_set_status AS enum (
CREATE TYPE IF NOT EXISTS data_set_status AS enum (
'pending',
'downloaded',
'processed'
);

CREATE TYPE data_set_type AS enum (
CREATE TYPE IF NOT EXISTS data_set_type AS enum (
'urbanization',
'footfall',
'landtype'
);

CREATE TABLE data_sets (
CREATE TABLE IF NOT EXISTS data_sets (
filename TEXT PRIMARY KEY,
data_set data_set_type NOT NULL,
time_to_use TIMESTAMPTZ NOT NULL,
Expand Down
4 changes: 1 addition & 3 deletions mobile_verifier/src/boosting_oracles/data_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,8 @@ async fn delete_old_data_sets(
let prefix = &cap[1];
let timestamp = cap[2].parse::<u64>()?.to_timestamp_millis()?;
if prefix == data_set_type.to_prefix() && timestamp < time_to_use {
let mut path = data_set_directory.to_path_buf();
path.push(data_set.path());
tracing::info!(data_set = &*file_name, "Deleting old data set file");
tokio::fs::remove_file(path).await?;
tokio::fs::remove_file(data_set.path()).await?;
}
}
Ok(())
Expand Down

0 comments on commit 7e447ab

Please sign in to comment.