Skip to content

fix: append extensions to midi and mp3 download filenames#170

Open
Blazzycrafter wants to merge 1 commit into
LibreScore:masterfrom
Blazzycrafter:fix/midi-mp3-download-extensions
Open

fix: append extensions to midi and mp3 download filenames#170
Blazzycrafter wants to merge 1 commit into
LibreScore:masterfrom
Blazzycrafter:fix/midi-mp3-download-extensions

Conversation

@Blazzycrafter

Copy link
Copy Markdown

Description

This pull request resolves an issue where downloaded MIDI and MP3 files were saved without their respective file extensions (.mid and .mp3).

The Problem

Previously, in src/main.ts, the BtnAction.download helper was called with scoreinfo.fileName as the target filename parameter for both MIDI and MP3 downloads. Because scoreinfo.fileName only returns the sanitized title of the sheet music without any file extension, the browser saved these files without an extension (e.g., as Song_Title instead of Song_Title.mid).

Unlike PDF downloads (where the .pdf extension is explicitly appended during the export process in src/pdf.ts), no file extension handling was present for the direct MIDI and MP3 downloads.

The Solution

We appended the missing .mid and .mp3 file extensions to the filename arguments in the BtnAction.download calls in src/main.ts:

  • Added + ".mid" to the MIDI download button action.
  • Added + ".mp3" to the MP3 download button action.

This ensures that the browser automatically saves the files with their correct extensions, preventing users from having to manually rename the downloaded files to open them.

Changes

In src/main.ts:

@@ -122,3 +122,3 @@
                 action: BtnAction.download(
                     () => getFileUrl(scoreinfo.id, "midi"),
-                    scoreinfo.fileName,
+                    scoreinfo.fileName + ".mid",
                     fallback,
@@ -132,3 +132,3 @@
                 action: BtnAction.download(
                     () => getFileUrl(scoreinfo.id, "mp3"),
-                    scoreinfo.fileName,
+                    scoreinfo.fileName + ".mp3",
                     fallback,

@Blazzycrafter

Copy link
Copy Markdown
Author

I ran CodeRabbit CLI locally on this branch, and it reported no findings or issues. The changes are clean and ready.

@Blazzycrafter Blazzycrafter marked this pull request as ready for review June 14, 2026 20:31
@Blazzycrafter

Copy link
Copy Markdown
Author

checked and change works.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant