summary refs log tree commit diff
path: root/Rhea/StoreMetaService.cs
blob: 6b92cd666bc6cc82628a1c6a5674505220140a3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using ArcaneLibs.Collections;

namespace Rhea;

public class StoreMetaService(RheaConfiguration cfg)
{
    private LruCache<string> _storePathsByBaseName = new(10000);

    public async Task<string?> GetStorePathByBaseName(string baseName)
    {
        return await _storePathsByBaseName.GetOrAddAsync(baseName, async () =>
        {
            foreach (var path in Directory.EnumerateFileSystemEntries(cfg.StorePath))
            {
                Console.WriteLine(path[(cfg.StorePath.Length + 1)..]);
                if (path.StartsWith(baseName + '-')) return path;
            }

            return "";
        });
    }
}