mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
refactor: centralize cache path logic and add TMPDIR documentation
This commit is contained in:
@@ -51,10 +51,11 @@ DOWNLOAD_MODE=Track
|
|||||||
# - Permanent: Files are saved to the library permanently and registered in Navidrome
|
# - Permanent: Files are saved to the library permanently and registered in Navidrome
|
||||||
# - Cache: Files are stored in /tmp and automatically cleaned up after CACHE_DURATION_HOURS
|
# - Cache: Files are stored in /tmp and automatically cleaned up after CACHE_DURATION_HOURS
|
||||||
# Not registered in Navidrome, ideal for streaming without library bloat
|
# Not registered in Navidrome, ideal for streaming without library bloat
|
||||||
|
# Note: On Linux/Docker, you can customize cache location by setting TMPDIR environment variable
|
||||||
STORAGE_MODE=Permanent
|
STORAGE_MODE=Permanent
|
||||||
|
|
||||||
# Cache duration in hours (optional, default: 1)
|
# Cache duration in hours (optional, default: 1)
|
||||||
# Files older than this duration will be automatically deleted when STORAGE_MODE=Cache
|
# Files older than this duration will be automatically deleted when STORAGE_MODE=Cache
|
||||||
# Based on last access time (updated each time the file is streamed)
|
# Based on last access time (updated each time the file is streamed)
|
||||||
# Cache location: /tmp/octo-fiesta-cache (automatic, no configuration needed)
|
# Cache location: /tmp/octo-fiesta-cache (or $TMPDIR/octo-fiesta-cache if TMPDIR is set)
|
||||||
CACHE_DURATION_HOURS=1
|
CACHE_DURATION_HOURS=1
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public abstract class BaseDownloadService : IDownloadService
|
|||||||
Logger = logger;
|
Logger = logger;
|
||||||
|
|
||||||
DownloadPath = configuration["Library:DownloadPath"] ?? "./downloads";
|
DownloadPath = configuration["Library:DownloadPath"] ?? "./downloads";
|
||||||
CachePath = Path.Combine(Path.GetTempPath(), "octo-fiesta-cache");
|
CachePath = PathHelper.GetCachePath();
|
||||||
|
|
||||||
if (!Directory.Exists(DownloadPath))
|
if (!Directory.Exists(DownloadPath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class CacheCleanupService : BackgroundService
|
|||||||
|
|
||||||
private async Task CleanupOldCachedFilesAsync(CancellationToken cancellationToken)
|
private async Task CleanupOldCachedFilesAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var cachePath = Path.Combine(Path.GetTempPath(), "octo-fiesta-cache");
|
var cachePath = PathHelper.GetCachePath();
|
||||||
|
|
||||||
if (!Directory.Exists(cachePath))
|
if (!Directory.Exists(cachePath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ namespace octo_fiesta.Services.Common;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class PathHelper
|
public static class PathHelper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the cache directory path for temporary file storage.
|
||||||
|
/// Uses system temp directory combined with octo-fiesta-cache subfolder.
|
||||||
|
/// Respects TMPDIR environment variable on Linux/macOS.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Full path to the cache directory.</returns>
|
||||||
|
public static string GetCachePath()
|
||||||
|
{
|
||||||
|
return Path.Combine(Path.GetTempPath(), "octo-fiesta-cache");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds the output path for a downloaded track following the Artist/Album/Track structure.
|
/// Builds the output path for a downloaded track following the Artist/Album/Track structure.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user