Lazily create session directories on first MP3 save
Session directories are now created only when the first MP3 file is saved, not at session creation. Added EnsureSessionDirectoryExists to ISessionService and SessionService to handle this logic. Updated VideoService to call this method before saving files. Cleanup now logs when no directory exists for expired sessions.
This commit is contained in:
@@ -104,9 +104,11 @@ public class VideoService : IVideoService
|
||||
throw new FileNotFoundException($"yt-dlp.exe not found at {ytDlpPath}");
|
||||
}
|
||||
|
||||
// Get session-specific download directory
|
||||
// Ensure session directory exists only when we're about to save the first MP3 file
|
||||
_sessionService.EnsureSessionDirectoryExists(sessionId);
|
||||
|
||||
// Get session-specific download directory (now guaranteed to exist)
|
||||
var downloadDir = _sessionService.GetSessionDownloadsPath(sessionId);
|
||||
Directory.CreateDirectory(downloadDir);
|
||||
|
||||
// Get video details first for better filename
|
||||
var videoDetails = await GetVideoDetailsAsync(url);
|
||||
|
||||
Reference in New Issue
Block a user