fix(audio): recover clip serverFileId from audio_file_url on project load
3 fixes for audio clips losing sound after save/reload: 1. deserializeTracksList: clip-level serverFileId falls back to extracting from audio_file_url when server_file_id missing 2. serializeTracksList: add server_file_id to track output so track-level fallback survives round-trip 3. upgrade_project_json_if_needed: include server_file_id in source_data during legacy project upgrade
This commit is contained in:
@@ -38,6 +38,7 @@ def upgrade_project_json_if_needed(project_data: dict) -> dict:
|
||||
"clip_start_offset_bars": 0.0,
|
||||
"source_data": {
|
||||
"audio_file_url": f"/static/audio/uploads/{t.get('serverFileId')}" if t.get("serverFileId") else "",
|
||||
"server_file_id": t.get("serverFileId") or None,
|
||||
"sample_rate": 44100,
|
||||
"channels": 2,
|
||||
"gain": 1.0
|
||||
|
||||
@@ -7634,6 +7634,7 @@ const serializeTracksList = (tracksList, secondsPerBar) => {
|
||||
soundfont_bank: t.soundfont_bank !== undefined ? t.soundfont_bank : (t.synth_engine ? t.synth_engine.soundfont_bank : null),
|
||||
soundfont_program: t.soundfont_program !== undefined ? t.soundfont_program : (t.synth_engine ? t.synth_engine.soundfont_program : null),
|
||||
synth_engine: t.synth_engine || undefined,
|
||||
server_file_id: t.serverFileId || null,
|
||||
items: items
|
||||
};
|
||||
});
|
||||
@@ -7648,7 +7649,7 @@ const deserializeTracksList = (schemaTracks, secondsPerBar, sectionStore) => {
|
||||
(t.items || []).forEach(item => {
|
||||
if (item.type === "AUDIO_ITEM") {
|
||||
const src = item.source_data || {};
|
||||
const clipFileId = src.server_file_id || null;
|
||||
const clipFileId = src.server_file_id || (src.audio_file_url ? src.audio_file_url.split('/').pop() : null) || null;
|
||||
clips.push({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user