MCPcopy Create free account
hub / github.com/capable-average/tagTonic / loadFile

Method loadFile

tui/app.go:254–294  ·  view source on GitHub ↗
(file *FileEntry)

Source from the content-addressed store, hash-verified

252}
253
254func (a *App) loadFile(file *FileEntry) tea.Cmd {
255 a.currentFile = file
256 a.isLoading = true
257
258 clearKittyImages()
259
260 statusCmd := a.setStatus("Loading: "+file.Name, 3)
261
262 loadCmd := func() tea.Msg {
263 result := make(chan tea.Msg, 1)
264
265 go func() {
266 tagEditor := mp3.NewTagEditor()
267 tags, err := tagEditor.ReadTags(file.Path)
268 if err != nil {
269 result <- FileLoadErrorMsg{
270 FilePath: file.Path,
271 Error: err,
272 }
273 return
274 }
275
276 result <- FileLoadedMsg{
277 FilePath: file.Path,
278 Tags: tags,
279 }
280 }()
281
282 select {
283 case msg := <-result:
284 return msg
285 case <-time.After(5 * time.Second):
286 return FileLoadErrorMsg{
287 FilePath: file.Path,
288 Error: fmt.Errorf("tag reading timed out"),
289 }
290 }
291 }
292
293 return tea.Batch(statusCmd, loadCmd)
294}
295
296func (a *App) saveTags() tea.Cmd {
297 if a.currentFile == nil {

Callers 1

handleFileBrowserKeysMethod · 0.95

Calls 4

setStatusMethod · 0.95
ReadTagsMethod · 0.95
NewTagEditorFunction · 0.92
clearKittyImagesFunction · 0.85

Tested by

no test coverage detected