Przeglądaj źródła

fix Windows path problem

tuanchris 5 miesięcy temu
rodzic
commit
3cfadc906c
2 zmienionych plików z 7 dodań i 0 usunięć
  1. 5 0
      modules/core/cache_manager.py
  2. 2 0
      modules/core/pattern_manager.py

+ 5 - 0
modules/core/cache_manager.py

@@ -56,10 +56,15 @@ def ensure_cache_dir():
 
 def get_cache_path(pattern_file):
     """Get the cache path for a pattern file."""
+    # Normalize path separators to handle both forward slashes and backslashes
+    pattern_file = pattern_file.replace('\\', '/')
+    
     # Create subdirectories in cache to match the pattern file structure
     cache_subpath = os.path.dirname(pattern_file)
     if cache_subpath:
         # Create the same subdirectory structure in cache (including custom_patterns)
+        # Convert forward slashes back to platform-specific separator for os.path.join
+        cache_subpath = cache_subpath.replace('/', os.sep)
         cache_dir = os.path.join(CACHE_DIR, cache_subpath)
     else:
         # For files in root pattern directory

+ 2 - 0
modules/core/pattern_manager.py

@@ -98,6 +98,8 @@ def list_theta_rho_files():
     for root, _, filenames in os.walk(THETA_RHO_DIR):
         for file in filenames:
             relative_path = os.path.relpath(os.path.join(root, file), THETA_RHO_DIR)
+            # Normalize path separators to always use forward slashes for consistency across platforms
+            relative_path = relative_path.replace(os.sep, '/')
             files.append(relative_path)
     logger.debug(f"Found {len(files)} theta-rho files")
     return [file for file in files if file.endswith('.thr')]