Fix UI/import minor bugs from Ultra Fuzz Run 1
- truncate_name in file_list_menus now counts chars, not bytes, so
multi-byte UTF-8 names don't panic on the slice
- theme_preview_colors looked up the wrong key prefix (bg./fg.) and
silently fell back to defaults — fixed to background./foreground.
- import dry-run skips macOS metadata dirs (__MACOSX, .DS_Store roots)
matching the actual import logic
- orphan delete in cleanup re-checks with NOT EXISTS to avoid racing
against a parallel re-import
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 files changed,
+15 insertions,
-10 deletions
| 197 |
197 |
|
current_name: name.clone(),
|
| 198 |
198 |
|
});
|
| 199 |
199 |
|
|
| 200 |
|
- |
// Delete from DB
|
| 201 |
|
- |
match db
|
| 202 |
|
- |
.conn()
|
| 203 |
|
- |
.execute("DELETE FROM samples WHERE hash = ?1", [hash])
|
| 204 |
|
- |
{
|
|
200 |
+ |
// Delete from DB — re-check orphan status to avoid racing with a concurrent import
|
|
201 |
+ |
// that may have linked this sample to a VFS node since the initial query.
|
|
202 |
+ |
match db.conn().execute(
|
|
203 |
+ |
"DELETE FROM samples WHERE hash = ?1 \
|
|
204 |
+ |
AND NOT EXISTS (SELECT 1 FROM vfs_nodes WHERE sample_hash = ?1)",
|
|
205 |
+ |
[hash],
|
|
206 |
+ |
) {
|
| 205 |
207 |
|
Ok(_) => {
|
| 206 |
208 |
|
// Delete from disk
|
| 207 |
209 |
|
if let Ok(path) = store.sample_path(hash, ext) {
|
| 13 |
13 |
|
for entry in entries.flatten() {
|
| 14 |
14 |
|
let path = entry.path();
|
| 15 |
15 |
|
if path.is_dir() {
|
| 16 |
|
- |
dirs.push(path);
|
|
16 |
+ |
if !audiofiles_core::util::is_macos_metadata_dir(&path) {
|
|
17 |
+ |
dirs.push(path);
|
|
18 |
+ |
}
|
| 17 |
19 |
|
} else if audiofiles_core::util::is_audio_file(&path) {
|
| 18 |
20 |
|
count += 1;
|
| 19 |
21 |
|
}
|
| 314 |
314 |
|
|
| 315 |
315 |
|
/// Truncate a name for display in menus (avoids excessively wide menu items).
|
| 316 |
316 |
|
fn truncate_name(name: &str, max_len: usize) -> String {
|
| 317 |
|
- |
if name.len() <= max_len {
|
|
317 |
+ |
if name.chars().count() <= max_len {
|
| 318 |
318 |
|
name.to_string()
|
| 319 |
319 |
|
} else {
|
| 320 |
|
- |
format!("{}...", &name[..max_len.saturating_sub(3)])
|
|
320 |
+ |
let truncated: String = name.chars().take(max_len.saturating_sub(3)).collect();
|
|
321 |
+ |
format!("{truncated}...")
|
| 321 |
322 |
|
}
|
| 322 |
323 |
|
}
|
| 323 |
324 |
|
|
| 401 |
401 |
|
|
| 402 |
402 |
|
let table: toml::Table = content.parse().ok()?;
|
| 403 |
403 |
|
let colors = theme_common::extract_colors(&table);
|
| 404 |
|
- |
let bg = get_color(&colors, "bg.primary").unwrap_or(Color32::from_rgb(30, 30, 30));
|
|
404 |
+ |
let bg = get_color(&colors, "background.primary").unwrap_or(Color32::from_rgb(30, 30, 30));
|
| 405 |
405 |
|
let accent = get_color(&colors, "accent.blue").unwrap_or(Color32::from_rgb(100, 100, 255));
|
| 406 |
|
- |
let fg = get_color(&colors, "fg.primary").unwrap_or(Color32::from_rgb(220, 220, 220));
|
|
406 |
+ |
let fg = get_color(&colors, "foreground.primary").unwrap_or(Color32::from_rgb(220, 220, 220));
|
| 407 |
407 |
|
Some((bg, accent, fg))
|
| 408 |
408 |
|
}
|
| 409 |
409 |
|
|