Compare commits

...

2 Commits

Author SHA1 Message Date
ᴀᴍᴛᴏᴀᴇʀ
e732e7d616 feat: 放宽数据库连接池的连接数和获取时间,避免 time out 错误 (#87) 2024-04-29 13:46:22 +08:00
amtoaer
f81d9fc6eb chore: 修改版本并添加许可证 2024-04-29 00:59:50 +08:00
4 changed files with 33 additions and 4 deletions

2
Cargo.lock generated
View File

@@ -418,7 +418,7 @@ dependencies = [
[[package]]
name = "bili-sync-rs"
version = "2.0.0"
version = "2.0.3"
dependencies = [
"anyhow",
"arc-swap",

View File

@@ -1,7 +1,10 @@
[package]
name = "bili-sync-rs"
version = "2.0.0"
version = "2.0.3"
edition = "2021"
authors = ["amtoaer <amtoaer@gmail.com>"]
license = "MIT"
description = "基于 rust tokio 编写的 bilibili 收藏夹同步下载工具"
[dependencies]
anyhow = { version = "1.0.81", features = ["backtrace"] }

21
Licence Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 ᴀᴍᴛᴏᴀᴇʀ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,13 +1,18 @@
use anyhow::Result;
use migration::{Migrator, MigratorTrait};
use sea_orm::{Database, DatabaseConnection};
use sea_orm::{ConnectOptions, Database, DatabaseConnection};
use tokio::fs;
use crate::config::CONFIG_DIR;
pub async fn database_connection() -> Result<DatabaseConnection> {
let target = CONFIG_DIR.join("data.sqlite");
fs::create_dir_all(&*CONFIG_DIR).await?;
Ok(Database::connect(format!("sqlite://{}?mode=rwc", target.to_str().unwrap())).await?)
let mut option = ConnectOptions::new(format!("sqlite://{}?mode=rwc", target.to_str().unwrap()));
option
.max_connections(100)
.min_connections(5)
.acquire_timeout(std::time::Duration::from_secs(90));
Ok(Database::connect(option).await?)
}
pub async fn migrate_database(connection: &DatabaseConnection) -> Result<()> {