Skip to content

Commit 32227e5

Browse files
authored
V1.0.3 (#19)
* updt crates * Fix BOM bug in CSV file * Fix: Dialog not closing in database config
1 parent e8c628f commit 32227e5

File tree

21 files changed

+1043
-991
lines changed

21 files changed

+1043
-991
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div align="center">
55
<img src="https://img.shields.io/badge/Rust-dea584?style=for-the-badge&logo=rust&logoColor=white" alt="Rust" />
66
<img src="https://img.shields.io/badge/Tauri-ffc130?style=for-the-badge&logo=tauri&logoColor=white" alt="Tauri" />
7-
<img src="https://img.shields.io/badge/Version-1.0.1-7073f6?style=for-the-badge" alt="Version" />
7+
<img src="https://img.shields.io/badge/Version-1.0.3-7073f6?style=for-the-badge" alt="Version" />
88
</div>
99
</div>
1010

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,45 @@
1010
"tauri": "tauri"
1111
},
1212
"dependencies": {
13-
"@radix-ui/react-checkbox": "^1.1.5",
14-
"@radix-ui/react-dialog": "^1.1.7",
15-
"@radix-ui/react-dropdown-menu": "^2.1.7",
13+
"@radix-ui/react-checkbox": "^1.3.2",
14+
"@radix-ui/react-dialog": "^1.1.14",
15+
"@radix-ui/react-dropdown-menu": "^2.1.15",
1616
"@radix-ui/react-icons": "^1.3.2",
17-
"@radix-ui/react-label": "^2.1.3",
18-
"@radix-ui/react-menubar": "^1.1.7",
19-
"@radix-ui/react-popover": "^1.1.7",
20-
"@radix-ui/react-radio-group": "^1.2.4",
21-
"@radix-ui/react-select": "^2.1.7",
22-
"@radix-ui/react-separator": "^1.1.3",
23-
"@radix-ui/react-slot": "^1.2.0",
24-
"@radix-ui/react-switch": "^1.1.4",
25-
"@radix-ui/react-tabs": "^1.1.4",
26-
"@radix-ui/react-tooltip": "^1.2.0",
27-
"@tauri-apps/api": "^2.4.1",
28-
"@tauri-apps/plugin-dialog": "~2.2.1",
17+
"@radix-ui/react-label": "^2.1.7",
18+
"@radix-ui/react-menubar": "^1.1.15",
19+
"@radix-ui/react-popover": "^1.1.14",
20+
"@radix-ui/react-radio-group": "^1.3.7",
21+
"@radix-ui/react-select": "^2.2.5",
22+
"@radix-ui/react-separator": "^1.1.7",
23+
"@radix-ui/react-slot": "^1.2.3",
24+
"@radix-ui/react-switch": "^1.2.5",
25+
"@radix-ui/react-tabs": "^1.1.12",
26+
"@radix-ui/react-tooltip": "^1.2.7",
27+
"@tauri-apps/api": "^2.5.0",
28+
"@tauri-apps/plugin-dialog": "~2.2.2",
2929
"class-variance-authority": "^0.7.1",
3030
"clsx": "^2.1.1",
3131
"cmdk": "1.0.0",
32-
"framer-motion": "^12.6.5",
32+
"framer-motion": "^12.17.0",
3333
"lucide-react": "^0.441.0",
3434
"next-themes": "^0.4.6",
3535
"react": "^18.3.1",
3636
"react-dom": "^18.3.1",
37-
"react-router-dom": "^6.30.0",
37+
"react-router-dom": "^6.30.1",
3838
"sonner": "^1.7.4",
3939
"tailwind-merge": "^2.6.0",
4040
"tailwindcss-animate": "^1.0.7"
4141
},
4242
"devDependencies": {
43-
"@tauri-apps/cli": "^2.4.1",
44-
"@types/node": "^22.14.1",
45-
"@types/react": "^18.3.20",
46-
"@types/react-dom": "^18.3.6",
47-
"@vitejs/plugin-react": "^4.3.4",
43+
"@tauri-apps/cli": "^2.5.0",
44+
"@types/node": "^22.15.31",
45+
"@types/react": "^18.3.23",
46+
"@types/react-dom": "^18.3.7",
47+
"@vitejs/plugin-react": "^4.5.2",
4848
"autoprefixer": "^10.4.21",
49-
"postcss": "^8.5.3",
49+
"postcss": "^8.5.4",
5050
"tailwindcss": "^3.4.17",
5151
"typescript": "^5.8.3",
52-
"vite": "^5.4.18"
52+
"vite": "^5.4.19"
5353
}
5454
}

pnpm-lock.yaml

Lines changed: 838 additions & 822 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "FileFlow"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
description = "An app to manipulate DBMS tables"
55
authors = ["Maxime-Cllt"]
66
edition = "2021"

src-tauri/src/fileflow/action/actions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use crate::fileflow::database::connection::Connection;
33
use crate::fileflow::enumeration::insertion_type::InsertionType;
44
use crate::fileflow::stuct::insert_config::InsertConfig;
55
use crate::fileflow::stuct::save_config::SaveConfig;
6+
use crate::fileflow::stuct::string_formater::StringFormatter;
67
use crate::fileflow::utils::constants::DATABASE_CONFIG_FILE;
78
use crate::fileflow::utils::csv_utils::{find_separator, read_first_line};
89
use crate::fileflow::utils::fileflowlib::{get_all_saved_configs, save_config};
9-
use crate::fileflow::utils::string_formater::{get_formated_column_names, sanitize_column};
1010
use csv::{Reader, ReaderBuilder};
1111
use std::fs::{File, Metadata};
1212
use std::sync::Arc;
@@ -35,10 +35,10 @@ pub async fn insert_csv_data(
3535
let first_line: String = read_first_line(&csv.file_path).expect("Failed to read first line"); // Read the first line of the file to detect the separator
3636
let separator: char = find_separator(&first_line).expect("Failed to find separator"); // Separator detection of the file
3737

38-
let final_columns_name: Vec<String> = get_formated_column_names(
38+
let final_columns_name: Vec<String> = StringFormatter::get_formated_column_names(
3939
&first_line
4040
.split(separator)
41-
.map(|s| sanitize_column(s))
41+
.map(|s| StringFormatter::sanitize_column(s))
4242
.collect::<Vec<String>>(),
4343
);
4444

src-tauri/src/fileflow/action/database_command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::fileflow::enumeration::database_engine::DatabaseEngine;
1111
use crate::fileflow::stuct::combo_item::ComboItem;
1212
use crate::fileflow::stuct::db_config::DbConfig;
1313
use crate::fileflow::stuct::download_config::DownloadConfig;
14-
use crate::fileflow::utils::string_formater::{escaped_record, sanitize_value};
1514
use csv::{Reader, StringRecord};
1615
use serde_json::{json, Value};
1716
use sqlx::Row;
@@ -20,6 +19,7 @@ use std::fs::File;
2019
use std::sync::Arc;
2120
use std::time::Instant;
2221
use tauri::{command, State};
22+
use crate::fileflow::stuct::string_formater::StringFormatter;
2323

2424
#[command]
2525
pub async fn connect_to_database(
@@ -215,7 +215,7 @@ pub async fn fast_insert(
215215

216216
for result in reader.records() {
217217
let values: String = match result {
218-
Ok(record) => escaped_record(record),
218+
Ok(record) => StringFormatter::escaped_record(record),
219219
Err(_) => continue,
220220
};
221221

@@ -284,7 +284,7 @@ pub async fn optimized_insert(
284284
let mut values: Vec<String> = Vec::with_capacity(record.len());
285285

286286
for (i, value) in record.iter().enumerate() {
287-
let sanitized_value: String = sanitize_value(value);
287+
let sanitized_value: String = StringFormatter::sanitize_value(value);
288288
let max_length: &mut usize = columns_size_map
289289
.get_mut(final_columns_name[i].as_str())
290290
.ok_or("Column name mismatch")

src-tauri/src/fileflow/database/database_actions.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::fileflow::database::sql_builder::{
33
build_copy_table_sql, build_create_with_fixed_size_sql, build_drop_statement_sql,
44
};
55
use crate::fileflow::enumeration::database_engine::DatabaseEngine;
6-
use crate::fileflow::enumeration::separator::SeparatorType;
76
use crate::fileflow::stuct::download_config::DownloadConfig;
87
use csv::{Writer, WriterBuilder};
98
use sqlx::{Column, Row};
@@ -16,20 +15,13 @@ pub async fn export_table(
1615
download_config: &DownloadConfig,
1716
table_name: &str,
1817
) -> Result<(), Box<dyn std::error::Error>> {
19-
const LIMIT: i32 = 5000;
18+
const LIMIT: i32 = 5_000;
2019
let mut offset: i32 = 0;
2120
let mut header_written: bool = false;
2221
let file_path: String = format!("{}/{table_name}_export.csv", download_config.location);
2322

24-
let separator: u8 = match download_config.separator {
25-
SeparatorType::Comma => b',',
26-
SeparatorType::Semicolon => b';',
27-
SeparatorType::Pipe => b'|',
28-
SeparatorType::Space => b' ',
29-
};
30-
3123
let mut wtr: Writer<File> = WriterBuilder::new()
32-
.delimiter(separator)
24+
.delimiter(download_config.separator.as_u8())
3325
.from_path(&file_path)
3426
.expect("Failed to create CSV writer");
3527

src-tauri/src/fileflow/enumeration/database_engine.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,3 @@ pub enum DatabaseEngine {
88
Postgres,
99
SQLite,
1010
}
11-
12-
// impl DatabaseEngine {
13-
// pub fn as_str(&self) -> &'static str {
14-
// match self {
15-
// DatabaseEngine::MariaDB => "mariadb",
16-
// DatabaseEngine::MySQL => "mysql",
17-
// DatabaseEngine::Postgres => "postgres",
18-
// DatabaseEngine::SQLite => "sqlite",
19-
// }
20-
// }
21-
// }

src-tauri/src/fileflow/enumeration/separator.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ pub enum SeparatorType {
99
Space,
1010
Pipe,
1111
}
12+
13+
impl SeparatorType {
14+
15+
/// Returns the separator as a u8.
16+
pub const fn as_u8(&self) -> u8 {
17+
match self {
18+
SeparatorType::Comma => b',',
19+
SeparatorType::Semicolon => b';',
20+
SeparatorType::Space => b' ',
21+
SeparatorType::Pipe => b'|',
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)