|
|
|
@ -18,11 +18,7 @@ use log::{error, info}; |
|
|
|
use rocket::futures::{self, channel::mpsc}; |
|
|
|
use rocket::futures::{self, channel::mpsc}; |
|
|
|
use ruma::{DeviceId, ServerName, UserId}; |
|
|
|
use ruma::{DeviceId, ServerName, UserId}; |
|
|
|
use serde::Deserialize; |
|
|
|
use serde::Deserialize; |
|
|
|
use std::{ |
|
|
|
use std::{collections::HashMap, fs::{self, remove_dir_all}, io::Write, sync::{Arc, RwLock}}; |
|
|
|
collections::HashMap, |
|
|
|
|
|
|
|
fs::remove_dir_all, |
|
|
|
|
|
|
|
sync::{Arc, RwLock}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
use tokio::sync::Semaphore; |
|
|
|
use tokio::sync::Semaphore; |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize)] |
|
|
|
#[derive(Clone, Debug, Deserialize)] |
|
|
|
@ -253,9 +249,11 @@ impl Database { |
|
|
|
|
|
|
|
|
|
|
|
let password = utils::string_from_bytes(&password); |
|
|
|
let password = utils::string_from_bytes(&password); |
|
|
|
|
|
|
|
|
|
|
|
if password.map_or(false, |password| { |
|
|
|
let password_not_exists = password.map_or(false, |password| { |
|
|
|
argon2::verify_encoded(&password, b"").unwrap_or(false) |
|
|
|
argon2::verify_encoded(&password, b"").unwrap_or(false) |
|
|
|
}) { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if password_not_exists { |
|
|
|
db.users.userid_password.insert(userid, b"")?; |
|
|
|
db.users.userid_password.insert(userid, b"")?; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -265,6 +263,22 @@ impl Database { |
|
|
|
info!("Migration: 1 -> 2 finished"); |
|
|
|
info!("Migration: 1 -> 2 finished"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if db.globals.database_version()? < 3 { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move media to filesystem
|
|
|
|
|
|
|
|
for r in db.media.mediaid_file.iter() { |
|
|
|
|
|
|
|
let (key, content) = r?; |
|
|
|
|
|
|
|
let path = db.globals.get_media_file(&key); |
|
|
|
|
|
|
|
let mut file = fs::File::create(path)?; |
|
|
|
|
|
|
|
file.write_all(&content)?; |
|
|
|
|
|
|
|
db.media.mediaid_file.remove(&key)?; |
|
|
|
|
|
|
|
db.media.mediaid_file.insert(&key, vec![])?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.globals.bump_database_version(3)?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info!("Migration: 2 -> 3 finished"); |
|
|
|
|
|
|
|
} |
|
|
|
// This data is probably outdated
|
|
|
|
// This data is probably outdated
|
|
|
|
db.rooms.edus.presenceid_presence.clear()?; |
|
|
|
db.rooms.edus.presenceid_presence.clear()?; |
|
|
|
|
|
|
|
|
|
|
|
|