Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
better sqlite store drop
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Apr 28, 2024
1 parent 9c6c861 commit b6d96d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion storage-node/src/cache/data_store_cache/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fs;
use async_trait::async_trait;
use bytes::Bytes;
use futures::StreamExt;
use log::warn;
use rusqlite::{Connection, DatabaseName, OpenFlags};
use tokio::sync::{
mpsc::{channel, Receiver},
Expand Down Expand Up @@ -89,7 +90,11 @@ impl<R: DataStoreReplacer<SqliteStoreReplacerKey, SqliteStoreReplacerValue>> Dro
for SqliteStoreCache<R>
{
fn drop(&mut self) {
fs::remove_file(self.sqlite_base_path.clone()).expect("remove sqlite db files failed");
if fs::metadata(&self.sqlite_base_path).is_ok() {
fs::remove_file(self.sqlite_base_path.clone()).expect("remove sqlite db files failed");
} else {
warn!("sqlite db file not found: {}", self.sqlite_base_path);
}
}
}

Expand Down

0 comments on commit b6d96d9

Please sign in to comment.