Skip to content

Commit 31700cb

Browse files
authored
Fix app v1.0.0 (#16)
* fix back * fix back * fix back
1 parent ba572b0 commit 31700cb

File tree

13 files changed

+334
-324
lines changed

13 files changed

+334
-324
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "publish"
1+
name: "Build and Release workflow"
22

33
on:
44
workflow_dispatch:
@@ -20,7 +20,7 @@ jobs:
2020
node-version: lts/*
2121

2222
- name: install pnpm
23-
run: npm install -g pnpm # Installe pnpm globalement
23+
run: npm install -g pnpm
2424

2525
- name: get version
2626
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
@@ -35,7 +35,7 @@ jobs:
3535
repo: context.repo.repo,
3636
tag_name: `app-v${process.env.PACKAGE_VERSION}`,
3737
name: `Desktop App v${process.env.PACKAGE_VERSION}`,
38-
body: 'Take a look at the assets to download and install this app.',
38+
body: 'A new release of FileFlow is available.',
3939
draft: true,
4040
prerelease: false
4141
})
@@ -85,7 +85,7 @@ jobs:
8585
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
8686
# webkitgtk 4.0 est pour Tauri v1 - webkitgtk 4.1 est pour Tauri v2.
8787

88-
- name: install frontend dependencies
88+
- name: Install frontend dependencies
8989
run: pnpm install # Utilise pnpm pour installer les dépendances frontend
9090

9191
- uses: tauri-apps/tauri-action@v0

README.md

Lines changed: 78 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,114 @@
1-
<div align=center>
2-
<img src="/src-tauri/icons/icon.png" width="100px" height="100px" alt="FileFlow" align="center" />
3-
<h1>FileFlow</h1>
4-
<div align="center">
5-
<img src="https://img.shields.io/badge/Rust-dea584?style=for-the-badge&logo=rust&logoColor=white" alt="Rust" />
6-
<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.0-7073f6?style=for-the-badge" alt="Version" />
8-
</div>
1+
<div align="center">
2+
<img src="/src-tauri/icons/icon.png" width="100px" height="100px" alt="FileFlow" align="center" />
3+
<h1>FileFlow</h1>
4+
<div align="center">
5+
<img src="https://img.shields.io/badge/Rust-dea584?style=for-the-badge&logo=rust&logoColor=white" alt="Rust" />
6+
<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.0-7073f6?style=for-the-badge" alt="Version" />
8+
</div>
99
</div>
1010

11-
<div align=center style="margin-top: 20px">
12-
<img src="/assets/FileFlowDemo.png" alt="FileFlow" width="65%" height="50%" />
13-
<img src="/assets/Load_data.png" alt="FileFlow" width="65%" height="50%" />
11+
<div align="center" style="margin-top: 20px">
12+
<img src="/assets/FileFlowDemo.png" alt="FileFlow" height="250px" width="auto" />
13+
<img src="/assets/Load_data.png" alt="FileFlow" height="250px" width="auto" />
1414
</div>
1515

16+
## 📄 Description
1617

17-
## Description
18+
FileFlow is a simple and easy-to-use tool that allows you to insert data from a CSV file directly into a database table.
19+
With no privilege required for insertion, it simplifies the process while offering efficiency.
1820

19-
FileFlow is a simple tool that allows you to insert data from a CSV file into a table in a database. It is designed to
20-
be simple to use and to require no privilege to insert the data.
21-
Build with Rust and the Tauri framework, it is a cross-platform application that can be used on Windows, MacOS and
22-
Linux.
21+
Built with **Rust** and the **Tauri** framework, FileFlow is a **cross-platform** application available on **Windows**,
22+
**MacOS**, and **Linux**. 🚀
2323

24-
See in the release section for the latest version of the application.
24+
Check the **Release Section** for the latest version of the application.
2525

26-
## Features
26+
## 🌟 Features
2727

28-
<label>
29-
<input type="checkbox" style="margin-right: 10px" checked>
30-
</label> Insert data into a new table <br>
31-
<label>
32-
<input type="checkbox" style="margin-right: 10px" checked>
33-
</label> Insert data into an existing table <br>
34-
<label>
35-
<input type="checkbox" style="margin-right: 10px" checked>
36-
</label> Optimise the type of the columns (VARCHAR(MAX_LENGHT)) <br>
37-
<label>
38-
<input type="checkbox" style="margin-right: 10px" checked>
39-
</label> From CSV file <br>
40-
<label>
41-
<input type="checkbox" style="margin-right: 10px" checked>
42-
</label> Don't require <span style="font-weight: bold;">ANY</span> privilege to insert the data <br>
43-
<label>
44-
<input type="checkbox" style="margin-right: 10px" checked>
45-
</label> Generate LOAD DATA sql query to insert faster<br>
28+
- ✅ Insert data into a **new table**
29+
- ✅ Insert data into an **existing table**
30+
-**Optimize** column types (e.g., `VARCHAR(MAX_LENGTH)`)
31+
- ✅ Insert data from a **CSV file**
32+
- ✅ Does **NOT** require **ANY** privileges for data insertion
33+
- ✅ Generate **LOAD DATA** SQL query for **faster insertion**
4634

47-
## Supported databases
35+
## 🛠 Supported Databases
4836

49-
<div align=center>
37+
<div align="center">
38+
<img src="https://img.shields.io/badge/MySQL-00758F?style=for-the-badge&logo=mysql&logoColor=white" alt="MySQL" />
39+
<img src="https://img.shields.io/badge/MariaDB-003545?style=for-the-badge&logo=mariadb&logoColor=white" alt="MariaDB" />
40+
<img src="https://img.shields.io/badge/PostgreSQL-336791?style=for-the-badge&logo=postgresql&logoColor=white" alt="PostgreSQL" />
41+
<img src="https://img.shields.io/badge/SQLite-003B57?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite" />
42+
</div>
5043

51-
![MySQL](https://img.shields.io/badge/MySQL-00758F?style=for-the-badge&logo=mysql&logoColor=white)
52-
![MySQL](https://img.shields.io/badge/MariaDB-003545?style=for-the-badge&logo=mariadb&logoColor=white)
53-
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-336791?style=for-the-badge&logo=postgresql&logoColor=white)
54-
![SQLite](https://img.shields.io/badge/SQLite-003B57?style=for-the-badge&logo=sqlite&logoColor=white)
44+
## 📝 Requirements
5545

56-
</div>
46+
- **Rust**
47+
- **Cargo**
48+
- **pnpm**
5749

58-
## Requirements
50+
You can follow the instructions on the [Tauri website](https://tauri.app/) to install **Rust** and **Cargo**.
5951

60-
- Rust
61-
- Cargo
62-
- pnpm
52+
## 📥 Installation
6353

64-
To install Rust and Cargo, you can follow the instructions on the Tauri website
54+
1. Clone the repository:
6555

66-
## Installation
56+
```bash
57+
git clone https://github.com/Maxime-Cllt/FileFlow.git
58+
```
6759

68-
1. Clone the repository
60+
2. Install the dependencies:
6961

70-
```bash
71-
git clone https://github.com/Maxime-Cllt/FileFlow.git
72-
```
62+
```bash
63+
cd FileFlow
64+
pnpm install
65+
```
7366

74-
2. Install the dependencies
67+
3. Build the application:
7568

76-
```bash
77-
cd FileFlow
78-
```
69+
```bash
70+
pnpm tauri build
71+
```
7972

80-
```bash
81-
pnpm install
82-
```
73+
4. Run the application:
8374

84-
3. Build the application
75+
```bash
76+
pnpm tauri dev
77+
```
8578

86-
```bash
87-
pnpm tauri build
88-
```
79+
## 💡 Usage
8980

90-
4. Run the application
81+
### 1. Insert Data
9182

92-
```bash
93-
pnpm tauri dev
94-
```
83+
- 📁 Select the **CSV file** you want to insert into the database.
84+
- 💻 Choose the **database** where you want to insert the data.
85+
- ➡️ Click the **"Insert"** button.
86+
- ⏳ Wait for the data to be inserted.
87+
- ✅ **Done!**
9588

96-
## Usage
89+
### 2. Generate Load Data
9790

98-
<ol>
99-
<li>Insert Data</li>
100-
<ul>
101-
<li>Select the CSV file you want to insert into the database</li>
102-
<li>Select the database you want to insert the data into</li>
103-
<li>Click on the "Insert" button</li>
104-
<li>Wait for the data to be inserted</li>
105-
<li>Done!</li>
106-
</ul>
107-
<li>Generate Load data</li>
108-
<ul>
109-
<li>Select the CSV file you want to insert into the database</li>
110-
<li>Click on the "Load" button in the menu</li>
111-
<li>Copy the generated SQL query</li>
112-
<li>Run the query if your database support it</li>
113-
<li>Done!</li>
114-
</ul>
115-
</ol>
91+
- 📁 Select the **CSV file** you want to insert into the database.
92+
- 🖱️ Click the **"Load"** button in the menu.
93+
- 📋 Copy the generated **SQL query**.
94+
- 🏃‍♂️ Run the query if your database supports it.
95+
- ✅ **Done!**
11696

117-
## Information
97+
## ⚙️ Modes of Data Insertion
11898

119-
There are two mode to insert the data into the database:
99+
There are two modes for inserting data into the database:
120100

121-
- **Optimised mode**: The data is inserted into a new table with the type of the columns optimised (VARCHAR(MAX_LENGHT))
122-
- **Fast mode**: The data is inserted into an existing table with the type of the columns as they are in the CSV file
101+
- **Optimized Mode**: Inserts data into a new table with optimized column types (e.g., `VARCHAR(MAX_LENGTH)`). 🛠️ This
102+
mode may take longer but ensures the table structure is optimized.
123103

124-
The optimised mode might take longer to insert the data but it will create a table with the type of the columns
125-
optimised.
104+
- **Fast Mode**: Inserts data into an existing table, keeping the original column types as they are in the CSV file. ⚡
105+
This mode is quicker but may not optimize the column types.
126106

127-
You can also generate a LOAD DATA SQL query to insert the data faster if your database support it. It is way faster than
128-
inserting the data row by row but not all databases support it.
107+
Additionally, you can generate a **LOAD DATA** SQL query for faster insertion if your database supports it. This method
108+
is much quicker than row-by-row insertion! 🚀
129109

110+
## 🤝 Contributing
130111

131-
## Contributing
112+
Want to contribute to the project? Feel free to open an issue or submit a pull request. We welcome contributions and
113+
ideas from the community! 💡
132114

133-
If you want to contribute to the project, you can open an issue or a pull request.

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
// src/fileflow/action/actions.rs
2-
31
use crate::fileflow::database::connection::Connection;
42
use crate::fileflow::fast_insert::fast_insert;
53
use crate::fileflow::optimized_insert::optimized_insert;
64
use crate::fileflow::stuct::insert_config::InsertConfig;
75
use crate::fileflow::stuct::save_config::SaveConfig;
86
use crate::fileflow::utils::constants::DATABASE_CONFIG_FILE;
97
use crate::fileflow::utils::fileflowlib::{
10-
detect_separator_in_file, get_all_saved_configs, get_formated_column_names, save_config,
8+
find_separator, get_all_saved_configs, get_formated_column_names, read_first_line, save_config,
119
};
1210
use csv::{Reader, ReaderBuilder};
1311
use std::fs::{File, Metadata};
@@ -26,29 +24,28 @@ pub async fn insert_csv_data(
2624
let conn_guard = state.0.lock().await;
2725

2826
if conn_guard.is_none() {
29-
return Err("No active database connection.".to_string());
27+
return Err("No active database connection.".into());
3028
}
3129

3230
let connection: &Connection = conn_guard.as_ref().unwrap();
3331
let start: Instant = Instant::now();
3432

3533
let file: File = File::open(&csv.file_path).unwrap();
36-
let separator: char = detect_separator_in_file(&csv.file_path).unwrap();
34+
35+
let first_line: String = read_first_line(&csv.file_path).unwrap();
36+
let separator: char = find_separator(&first_line)?;
37+
let final_columns_name: Vec<String> = get_formated_column_names(
38+
first_line
39+
.split(separator)
40+
.map(|s| s.replace("\"", ""))
41+
.collect(),
42+
);
3743

3844
let mut reader: Reader<File> = ReaderBuilder::new()
3945
.delimiter(separator as u8)
4046
.has_headers(true)
4147
.from_reader(file);
4248

43-
let final_columns_name: Vec<String> = get_formated_column_names(
44-
reader
45-
.headers()
46-
.unwrap()
47-
.iter()
48-
.map(|h| h.to_string())
49-
.collect(),
50-
);
51-
5249
let line_count: u64 = if csv.mode == "fast" {
5350
fast_insert(
5451
connection,
@@ -72,8 +69,8 @@ pub async fn insert_csv_data(
7269
Ok(format!(
7370
"Data inserted successfully in {:.2?}, {} rows inserted in table {}",
7471
start.elapsed(),
75-
&line_count,
76-
&csv.table_name
72+
line_count,
73+
csv.table_name
7774
))
7875
}
7976

@@ -83,7 +80,7 @@ pub async fn save_database_config(save: SaveConfig) -> Result<String, String> {
8380

8481
for config in &existing_configs {
8582
if config.config_name == save.config_name {
86-
return Err("Database configuration already exists".to_string());
83+
return Err("Database configuration already exists".into());
8784
}
8885
}
8986
let config_names: &str = &save.config_name.clone();
@@ -114,7 +111,7 @@ pub async fn load_database_config_by_name(name: String) -> Result<String, String
114111
.map_err(|e| format!("Failed to serialize config: {e}"));
115112
}
116113
}
117-
Err("Database configuration not found".to_string())
114+
Err("Database configuration not found".into())
118115
}
119116

120117
#[command]
@@ -133,7 +130,7 @@ pub async fn delete_database_config(name: String) -> Result<String, String> {
133130
}
134131

135132
if !found {
136-
Err("Database configuration not found".to_string())?;
133+
Err(String::from("Database configuration not found"))?;
137134
}
138135

139136
save_config(&new_configs, DATABASE_CONFIG_FILE)
@@ -147,10 +144,10 @@ pub async fn get_size_of_file(file_path: String) -> Result<String, String> {
147144
let metadata: Metadata =
148145
std::fs::metadata(&file_path).map_err(|e| format!("Failed to get metadata: {e}"))?;
149146
if !metadata.is_file() {
150-
return Err("Path is not a file".to_string());
147+
return Err("Path is not a file".into());
151148
}
152149
if metadata.len() == 0 {
153-
return Err("File is empty".to_string());
150+
return Err("File is empty".into());
154151
}
155152
let size: f64 = metadata.len() as f64 / 1024.0 / 1024.0;
156153
Ok(format!("{size:.2} MB"))

0 commit comments

Comments
 (0)