mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-26 04:42:00 +01:00
fix(cache): remove regex compiler cache, reload cache after ANY git revert
This commit is contained in:
@@ -33,14 +33,7 @@ def revert_file(repo_path, file_path):
|
||||
message = f"New file {file_path} has been removed."
|
||||
except FileNotFoundError:
|
||||
message = f"File {file_path} was already removed."
|
||||
return True, message
|
||||
|
||||
# Check if file is staged for deletion
|
||||
staged_deletions = repo.index.diff("HEAD", R=True)
|
||||
is_staged_for_deletion = any(d.a_path == file_path
|
||||
for d in staged_deletions)
|
||||
|
||||
if is_staged_for_deletion:
|
||||
elif is_staged_for_deletion:
|
||||
# Restore file staged for deletion
|
||||
repo.git.reset("--", file_path)
|
||||
repo.git.checkout('HEAD', "--", file_path)
|
||||
@@ -51,7 +44,7 @@ def revert_file(repo_path, file_path):
|
||||
repo.git.restore('--staged', "--", file_path)
|
||||
message = f"File {file_path} has been reverted."
|
||||
|
||||
# Reload cache after revert
|
||||
# Reload cache after ANY revert operation
|
||||
from ...data.cache import data_cache
|
||||
data_cache.initialize(force_reload=True)
|
||||
|
||||
|
||||
@@ -9,16 +9,6 @@ from .logger import get_import_logger
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Cache patterns at module level to avoid reloading
|
||||
_CACHED_PATTERNS = None
|
||||
|
||||
def get_cached_patterns():
|
||||
"""Get cached regex patterns, loading them once on first access."""
|
||||
global _CACHED_PATTERNS
|
||||
if _CACHED_PATTERNS is None:
|
||||
_CACHED_PATTERNS = load_regex_patterns()
|
||||
return _CACHED_PATTERNS
|
||||
|
||||
|
||||
def compile_format_to_api_structure(
|
||||
format_yaml: Dict[str, Any],
|
||||
@@ -35,7 +25,7 @@ def compile_format_to_api_structure(
|
||||
Compiled format ready for API
|
||||
"""
|
||||
target_app = TargetApp.RADARR if arr_type.lower() == 'radarr' else TargetApp.SONARR
|
||||
patterns = get_cached_patterns()
|
||||
patterns = load_regex_patterns()
|
||||
|
||||
compiled = {
|
||||
'name': format_yaml.get('name', 'Unknown')
|
||||
|
||||
Reference in New Issue
Block a user