Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ MODELS_DIR=./models
# ACESTEP_CPP_BRANCH=main

# ── Storage ───────────────────────────────────────────────────────────────────
AUDIO_DIR=./public/audio
# Audio directory for generated songs and uploaded reference tracks.
# Relative paths are resolved from the project root (APP_ROOT).
# This is the single source of truth: LocalStorageProvider (writes),
# Express /audio/ endpoint (serves), and the spawn service (reads) all use it.
AUDIO_DIR=./server/public/audio

# ── Auth ──────────────────────────────────────────────────────────────────────
# Change this to a long random string in any multi-user or network-exposed setup.
Expand Down
43 changes: 0 additions & 43 deletions backend/README.md

This file was deleted.

9 changes: 5 additions & 4 deletions server/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ export const config = {

storage: {
provider: 'local' as const,
// Audio directory must match where LocalStorageProvider writes files and
// where Express serves /audio/ from (server/src/index.ts: '../public/audio').
// Both resolve to <server_root>/public/audio, so we use SERVER_ROOT here.
// AUDIO_DIR env override is still supported (resolved against APP_ROOT).
// Single source of truth for the audio directory.
// LocalStorageProvider, Express (/audio/), and the spawn service all read
// this value so they always point at the same filesystem location.
// Default: <server_root>/public/audio (SERVER_ROOT = server/).
// Override via AUDIO_DIR in .env (relative paths are resolved from APP_ROOT).
audioDir: resolveFromRoot(process.env.AUDIO_DIR || path.join(SERVER_ROOT, 'public', 'audio')),
},

Expand Down
5 changes: 3 additions & 2 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ app.use(cors({

app.use(express.json());

// Serve static audio files
app.use('/audio', express.static(path.join(__dirname, '../public/audio')));
// Serve static audio files from the configured audio directory so that any
// AUDIO_DIR env override is honoured consistently across upload, spawn, and serving.
app.use('/audio', express.static(config.storage.audioDir));

// Audio Editor (AudioMass) - needs relaxed CSP for inline scripts and external images
app.use('/editor', (req, res, next) => {
Expand Down
3 changes: 2 additions & 1 deletion server/src/services/acestep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ async function runViaSpawn(
const batchSize = Math.min(Math.max(params.batchSize ?? 1, 1), 8);
if (batchSize > 1) ditArgs.push('--batch', String(batchSize));

// Cover and repaint modes both require a source audio file
// Cover and repaint modes both require a source audio file.
// dit-vae reads WAV or MP3 natively (via dr_wav / dr_mp3 in audio.h).
if (params.sourceAudioUrl) {
const srcAudioPath = resolveAudioPath(params.sourceAudioUrl);
ditArgs.push('--src-audio', srcAudioPath);
Expand Down
11 changes: 5 additions & 6 deletions server/src/services/storage/local.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { writeFile, unlink, stat, mkdir, copyFile } from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import type { StorageProvider } from './index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const AUDIO_DIR = path.join(__dirname, '../../../public/audio');
import { config } from '../../config/index.js';

export class LocalStorageProvider implements StorageProvider {
private audioDir: string;

constructor() {
this.audioDir = AUDIO_DIR;
// Derive the audio directory from the central config so that the storage
// provider always writes to the same location the spawn service resolves
// paths from (config.storage.audioDir, which honours the AUDIO_DIR env var).
this.audioDir = config.storage.audioDir;
}

async upload(key: string, data: Buffer, _contentType: string): Promise<string> {
Expand Down
Loading