[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Refactor import_tracks

Kasper (Sep 16, 2025, 7:02 AM +0200) 31beebe8 34965a18

+10 -9
+10 -9
src/lib/data.ts
··· 120 120 } 121 121 122 122 export async function import_tracks(paths: string[]) { 123 - let err_state = null 123 + let skip_all_errors = false 124 124 const now = Date.now() 125 - for (const path of paths) { 125 + for (const [i, path] of paths.entries()) { 126 + const is_last = i === paths.length - 1 126 127 try { 127 128 inner_addon.import_file(path, now) 128 129 } catch (err) { 129 - if (err_state === 'skip') continue 130 + if (skip_all_errors) { 131 + continue 132 + } 130 133 const result = await ipc_renderer.invoke('showMessageBox', false, { 131 134 type: 'error', 132 135 message: 'Error importing track ' + path, 133 136 detail: get_error_message(err), 134 - buttons: err_state ? ['OK', 'Skip all errors'] : ['OK'], 137 + buttons: !is_last ? ['OK', 'Skip all errors'] : ['OK'], 135 138 defaultId: 0, 136 139 }) 137 - if (result.response === 1) err_state = 'skip' 138 - else err_state = 'skippable' 140 + if (result.response === 1) { 141 + skip_all_errors = true 142 + } 139 143 } 140 144 } 141 145 tracklist_updated.emit() ··· 146 150 return strict_call((data) => data.get_default_sort_desc(field)) 147 151 } 148 152 149 - export function import_track(path: string, now: MsSinceUnixEpoch) { 150 - call((data) => data.import_file(path, now)) 151 - } 152 153 export function get_track(id: TrackID) { 153 154 return strict_call((data) => data.get_track(id)) 154 155 }