Skip to content

Commit c02d9f3

Browse files
committed
snapshot
1 parent b951efc commit c02d9f3

5 files changed

Lines changed: 24 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ strip = true
1212
[workspace.dependencies]
1313
diesel = { version = "2.2.0", features = [
1414
"sqlite",
15+
# "mysql",
16+
# "postgres",
1517
"chrono",
1618
"returning_clauses_for_sqlite_3_35",
1719
] }

file_classification_core/src/database.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
pub use diesel::{sqlite::SqliteConnection, Connection};
1+
pub use diesel::{Connection, QueryResult, sqlite::SqliteConnection};
22
use dotenvy::dotenv;
33
use std::env;
44

5+
// #[derive(diesel::MultiConnection)]
6+
// pub enum AnyConnection {
7+
// Postgresql(diesel::PgConnection),
8+
// Mysql(diesel::MysqlConnection),
9+
// Sqlite(diesel::SqliteConnection),
10+
// }
11+
512
pub fn establish_connection() -> SqliteConnection {
613
dotenv().ok();
14+
// NOTE: from ./.env
715
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
816
SqliteConnection::establish(&database_url)
917
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))

file_classification_core/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,26 @@ impl Display for AppError {
4242
AppError::GroupNotFound => write!(f, "Group not found"),
4343
AppError::CreateGroupFailed(msg) => write!(f, "Create group failed: {}", msg),
4444
AppError::DeleteGroupFailed(msg) => write!(f, "Delete group failed: {}", msg),
45+
4546
AppError::FileNotFound => write!(f, "File not found"),
4647
AppError::CreateFileFailed(msg) => write!(f, "Create file failed: {}", msg),
4748
AppError::DeleteFileFailed(msg) => write!(f, "Delete file failed: {}", msg),
49+
4850
AppError::TagNotFound => write!(f, "Tag not found"),
4951
AppError::CreateTagFailed(msg) => write!(f, "Create tag failed: {}", msg),
5052
AppError::DeleteTagFailed(msg) => write!(f, "Delete tag failed: {}", msg),
53+
5154
AppError::GroupTagNotFound => write!(f, "GroupTag not found"),
5255
AppError::CannotAssociateWithPrimary => write!(f, "Cannot associate with primary group"),
5356
AppError::CreateGroupTagFailed(msg) => write!(f, "Create GroupTag failed: {}", msg),
5457
AppError::DeleteGroupTagFailed(msg) => write!(f, "Delete GroupTag failed: {}", msg),
58+
5559
AppError::FileGroupNotFound => write!(f, "FileGroup not found"),
5660
AppError::CreateFileGroupFailed(msg) => write!(f, "Create FileGroup failed: {}", msg),
5761
AppError::DeleteFileGroupFailed(msg) => write!(f, "Delete FileGroup failed: {}", msg),
62+
5863
AppError::ValidationError(msg) => write!(f, "Validation error: {}", msg),
64+
5965
AppError::DieselError(e) => write!(f, "Database error: {}", e),
6066
// other Errors...
6167
_ => write!(f, "Unknown error occurred"),

nix/file_classification_cli.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
rev ? "unknown",
55
date ? "19700101",
66
sqlite,
7+
mysql80,
8+
postgresql,
9+
pkg-config,
710
lib,
811
...
912
}: let
@@ -21,6 +24,8 @@ in
2124
inherit src;
2225
nativeBuildInputs = [sqlite];
2326
buildInputs = [sqlite];
27+
# nativeBuildInputs = [pkg-config sqlite mysql80 postgresql];
28+
# buildInputs = [pkg-config sqlite mysql80 postgresql];
2429
pname = manifest.name;
2530
version = manifest.version;
2631
cargoLock.lockFile = ../Cargo.lock;

nix/shell.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ in
2323
pkgs.diesel-cli
2424

2525
pkgs.bashInteractive
26+
27+
pkgs.pkg-config
2628
]
2729
++ (oa.nativeBuildInputs or []);
2830

0 commit comments

Comments
 (0)