Skip to content

Commit 3100427

Browse files
committed
Cleanup Tauri code and update documentation
1 parent 379db03 commit 3100427

File tree

20 files changed

+250
-2272
lines changed

20 files changed

+250
-2272
lines changed

.github/workflows/pr-check-tests.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -88,47 +88,3 @@ jobs:
8888
cd backend
8989
pytest
9090
91-
# Tauri Test Job
92-
tauri:
93-
runs-on: ubuntu-latest
94-
name: Tauri Tests
95-
steps:
96-
- name: Checkout Code
97-
uses: actions/checkout@v3
98-
99-
- name: Install Dependencies for Tauri
100-
run: |
101-
sudo apt-get update -y
102-
103-
echo "deb http://archive.ubuntu.com/ubuntu jammy main universe multiverse" | sudo tee /etc/apt/sources.list.d/ubuntu-jammy.list
104-
105-
echo "deb http://security.ubuntu.com/ubuntu jammy-security main universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ubuntu-jammy-security.list
106-
107-
sudo apt-get update -y
108-
109-
sudo apt-get install -y \
110-
curl build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev \
111-
wget xz-utils libssl-dev libglib2.0-dev libgirepository1.0-dev pkg-config \
112-
software-properties-common libjavascriptcoregtk-4.0-dev libjavascriptcoregtk-4.1-dev \
113-
libsoup-3.0-dev libwebkit2gtk-4.1-dev librsvg2-dev file libglib2.0-dev libgl1-mesa-glx
114-
115-
- name: Set up Rust
116-
uses: actions-rs/toolchain@v1
117-
with:
118-
toolchain: stable
119-
override: true
120-
121-
- name: Set up Node.js
122-
uses: actions/setup-node@v3
123-
with:
124-
node-version: "18"
125-
126-
- name: Install Frontend Dependencies
127-
run: |
128-
cd frontend
129-
npm install
130-
131-
- name: Run Tauri Tests
132-
run: |
133-
cd frontend/src-tauri
134-
cargo test
2.94 MB
Loading
4.97 MB
Loading
306 KB
Loading

docs/backend/backend_rust/api.md

Lines changed: 7 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,238 +1,26 @@
11
## API Documentation
22

3-
The Rust backend provides the following commands that can be invoked from the frontend:
3+
The Rust backend provides the following command that can be invoked from the frontend:
44

5-
### 1. get_folders_with_images
6-
7-
- **Description**: Retrieves folders containing images from a specified directory.
8-
- **Parameters**:
9-
- `directory`: String
10-
- **Returns**: `Vec<PathBuf>`
11-
12-
### 2. get_images_in_folder
13-
14-
- **Description**: Gets all images in a specific folder.
15-
- **Parameters**:
16-
- `folder_path`: String
17-
- **Returns**: `Vec<PathBuf>`
18-
19-
### 3. get_all_images_with_cache
20-
21-
- **Description**: Retrieves all images from multiple directories, organized by year and month, with caching.
22-
- **Parameters**:
23-
- `directories`: Vec<String>
24-
- **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>`
25-
26-
### 4. get_all_videos_with_cache
27-
28-
- **Description**: Retrieves all videos from multiple directories, organized by year and month, with caching.
29-
- **Parameters**:
30-
- `directories`: Vec<String>
31-
- **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>`
32-
33-
### 5. delete_cache
34-
35-
- **Description**: Deletes all cached data.
36-
- **Parameters**: None
37-
- **Returns**: `bool`
38-
39-
### 6. share_file
40-
41-
- **Description**: Opens the file in the system's default file manager and selects it.
42-
- **Parameters**:
43-
- `path`: String
44-
- **Returns**: `Result<(), String>`
45-
46-
### 7. save_edited_image
47-
48-
- **Description**: Saves an edited image with applied filters and adjustments.
49-
- **Parameters**:
50-
- `image_data`: Vec<u8>
51-
- `save_path`: String
52-
- `filter`: String
53-
- `brightness`: i32
54-
- `contrast`: i32
55-
- `vibrance`: i32
56-
- `exposure`: i32
57-
- `temperature`: i32
58-
- `sharpness`: i32
59-
- `vignette`: i32
60-
- `highlights`: i32
61-
- **Returns**: `Result<(), String>`
62-
63-
### 8. get_server_path
5+
### get_server_path
646

657
- **Description**: Retrieves the path to the server resources directory.
668
- **Parameters**: *None*
679
- **Returns**: `Result<String, String>`
68-
### 9. move_to_secure_folder
69-
70-
- **Description**: Moves a file to the secure folder with encryption.
71-
- **Parameters**:
72-
- `path`: String
73-
- `password`: String
74-
- **Returns**: `Result<(), String>`
75-
76-
### 10. create_secure_folder
77-
78-
- **Description**: Creates a new secure folder with password protection.
79-
- **Parameters**:
80-
- `password`: String
81-
- **Returns**: `Result<(), String>`
82-
83-
### 11. unlock_secure_folder
84-
85-
- **Description**: Unlocks the secure folder with the provided password.
86-
- **Parameters**:
87-
- `password`: String
88-
- **Returns**: `Result<bool, String>`
89-
90-
### 12. get_secure_media
91-
92-
- **Description**: Retrieves all media files from the secure folder.
93-
- **Parameters**:
94-
- `password`: String
95-
- **Returns**: `Result<Vec<SecureMedia>, String>`
96-
97-
### 13. remove_from_secure_folder
98-
99-
- **Description**: Removes a file from the secure folder.
100-
- **Parameters**:
101-
- `file_name`: String
102-
- `password`: String
103-
- **Returns**: `Result<(), String>`
104-
105-
### 14. check_secure_folder_status
106-
107-
- **Description**: Checks if the secure folder is set up.
108-
- **Parameters**: None
109-
- **Returns**: `Result<bool, String>`
110-
111-
### 15. get_random_memories
112-
113-
- **Description**: Retrieves random memory images from specified directories.
114-
- **Parameters**:
115-
- `directories`: Vec<String>
116-
- `count`: usize
117-
- **Returns**: `Result<Vec<MemoryImage>, String>`
118-
119-
### 16. open_folder
120-
121-
- **Description**: Opens the parent folder of the specified file path.
122-
- **Parameters**:
123-
- `path`: String
124-
- **Returns**: `Result<(), String>`
125-
126-
### 17. open_with
127-
128-
- **Description**: Opens a file with the system's "Open With" dialog.
129-
- **Parameters**:
130-
- `path`: String
131-
- **Returns**: `Result<(), String>`
132-
133-
### 18. set_wallpaper
134-
135-
- **Description**: Sets an image as the desktop wallpaper.
136-
- **Parameters**:
137-
- `path`: String
138-
- **Returns**: `Result<(), String>`
139-
140-
## Data Structures
141-
142-
### SecureMedia
143-
144-
```rust
145-
pub struct SecureMedia {
146-
pub id: String,
147-
pub url: String,
148-
pub path: String,
149-
}
150-
```
151-
152-
### MemoryImage
153-
154-
```rust
155-
pub struct MemoryImage {
156-
path: String,
157-
created_at: DateTime<Utc>,
158-
}
159-
```
16010

16111
## Usage Examples
16212

16313
```javascript
16414
// In your frontend JavaScript/TypeScript code:
16515
import { invoke } from "@tauri-apps/api/tauri";
16616

167-
// Example: Get all images with cache from multiple directories
168-
const imagesData = await invoke("get_all_images_with_cache", {
169-
directories: ["/path/to/images1", "/path/to/images2"],
170-
});
171-
172-
// Example: Share a file
173-
await invoke("share_file", { path: "/path/to/file.jpg" });
174-
175-
// Example: Save edited image
176-
await invoke("save_edited_image", {
177-
image_data: imageBytes,
178-
save_path: "/path/to/save/edited.jpg",
179-
filter: "grayscale(100%)",
180-
brightness: 10,
181-
contrast: 20,
182-
vibrance: 15,
183-
exposure: 5,
184-
temperature: 0,
185-
sharpness: 10,
186-
vignette: 0,
187-
highlights: 0
188-
});
189-
190-
// Example: Create secure folder
191-
await invoke("create_secure_folder", { password: "mySecurePassword" });
192-
193-
// Example: Move file to secure folder
194-
await invoke("move_to_secure_folder", {
195-
path: "/path/to/file.jpg",
196-
password: "mySecurePassword"
197-
});
198-
199-
// Example: Get random memories
200-
const memories = await invoke("get_random_memories", {
201-
directories: ["/path/to/photos"],
202-
count: 5
203-
});
204-
205-
// Example: Set wallpaper
206-
await invoke("set_wallpaper", { path: "/path/to/wallpaper.jpg" });
207-
208-
// Example: Delete cache
209-
const cacheDeleted = await invoke("delete_cache");
17+
// Example: Get server path
18+
const serverPath = await invoke("get_server_path");
19+
console.log("Server path:", serverPath);
21020
```
21121

212-
## Key Components
213-
214-
- **FileService**: Handles file system operations for images and videos.
215-
- **CacheService**: Manages caching of folders, images, and videos.
216-
- **FileRepository**: Interacts directly with the file system to retrieve file information.
217-
- **CacheRepository**: Handles reading from and writing to cache files.
218-
- **Secure Storage**: Provides encrypted storage functionality with password protection.
219-
- **Image Processing**: Handles image editing operations including filters, brightness, contrast, and other adjustments.
220-
- **System Integration**: Provides integration with the operating system for file operations, wallpaper setting, and file management.
221-
222-
## Security Features
223-
224-
The API includes comprehensive security features for protecting sensitive media:
225-
226-
- **Encryption**: Files moved to secure folders are encrypted using AES-256-GCM
227-
- **Password Protection**: Secure folders require password authentication
228-
- **Salt-based Hashing**: Uses PBKDF2 with SHA-256 for password hashing
229-
- **Secure Random**: Uses cryptographically secure random number generation
230-
23122
## Cross-Platform Support
23223

233-
The API provides cross-platform support for:
234-
- **Windows**: File operations, wallpaper setting, and system integration
235-
- **macOS**: Native file operations and AppleScript integration
236-
- **Linux**: Support for GNOME and KDE desktop environments
24+
The API provides cross-platform support using Tauri's unified `AppHandle.path().resolve(..., BaseDirectory::Resource)` for path resolution across Windows, macOS, and Linux.
23725

238-
This backend architecture provides efficient file management, caching capabilities, secure storage, image processing, and system integration, enhancing the overall functionality of the Tauri application.
26+
This backend provides essential path resolution functionality for the Tauri application.

0 commit comments

Comments
 (0)