From f3c2a6bfdfb7b82a0a96585fc603dafc8be99696 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 3 Sep 2026 16:20:28 +0100 Subject: [PATCH] Fix cache retrieval - it was retrieving old file names if you upload the same file with different names. --- harmony_api/routers/text_router.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/harmony_api/routers/text_router.py b/harmony_api/routers/text_router.py index bf12d60..e0dd4f7 100644 --- a/harmony_api/routers/text_router.py +++ b/harmony_api/routers/text_router.py @@ -28,6 +28,7 @@ import uuid from typing import Annotated from typing import List +import re from fastapi import APIRouter, Body, status, Depends, Query from harmony.matching.default_matcher import match_instruments_with_function @@ -170,7 +171,12 @@ def parse_instruments( instrument_key = instruments_cache.generate_key(file.content) if instruments_cache.has(instrument_key): # If instruments are cached - instruments.extend(instruments_cache.get(instrument_key)) + instruments_from_cache = instruments_cache.get(instrument_key) + for instrument_from_cache in instruments_from_cache: + instrument_from_cache_copied = instrument_from_cache + instrument_from_cache_copied.file_name = file.file_name + instrument_from_cache_copied.instrument_name = re.sub(r"(?i)\.pdf$", "", file.file_name) + instruments.append(instrument_from_cache) else: # If instruments are not cached files_with_no_cached_instruments.append(file)