Removed session so it is part of the database.

This commit is contained in:
2023-02-02 21:55:18 -05:00
parent ca418136a7
commit 77c0f9f189
2 changed files with 4 additions and 72 deletions

View File

@ -1,6 +1,5 @@
mod databases;
pub mod error;
mod session;
use async_std::{
fs::{create_dir, read, remove_file, write},
@ -11,7 +10,6 @@ use async_std::{
use databases::Databases;
use error::DBError;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use session::Session;
use std::{
collections::HashMap,
fmt, slice, str,
@ -132,7 +130,7 @@ impl fmt::Display for CacheEntry {
pub struct MoreThanText {
cache: Arc<Mutex<HashMap<String, CacheEntry>>>,
dir: String,
session: Session,
session: Vec<String>,
}
impl MoreThanText {
@ -151,7 +149,7 @@ impl MoreThanText {
let mut output = Self {
cache: Arc::new(Mutex::new(HashMap::new())),
dir: data_dir.to_str().unwrap().to_string(),
session: Session::new(),
session: Vec::new(),
};
let entry_file = Path::new(dir).join(ENTRY);
let id: String;
@ -343,7 +341,7 @@ mod init {
let id = str::from_utf8(&data).unwrap();
let cache = db.get_entry(&id).await.unwrap();
assert_eq!(cache.data.entry_type(), "DBMap");
assert_eq!(db.session.get_data(), [id]);
assert_eq!(db.session, [id]);
}
#[async_std::test]
@ -355,11 +353,7 @@ mod init {
let db2 = MoreThanText::new(dir.path().to_str().unwrap())
.await
.unwrap();
assert_eq!(
db1.session.get_data(),
db2.session.get_data(),
"Did not read existing entry."
);
assert_eq!(db1.session, db2.session, "Did not read existing entry.");
}
}