|
|
@@ -173,6 +173,21 @@ def parse_file(
|
|
|
"""Parse file at given filepath: return a dictionary with meta
|
|
|
dictionary and list of blocks.
|
|
|
"""
|
|
|
+
|
|
|
+ logger.error(f"PARSE_FILE DEBUG: Parsing file: {input_path}")
|
|
|
+ logger.error(f"PARSE_FILE DEBUG: Absolute path: {Path(input_path).absolute()}")
|
|
|
+ logger.error(f"PARSE_FILE DEBUG: File exists: {Path(input_path).exists()}")
|
|
|
+
|
|
|
+ # Read first few lines for debugging
|
|
|
+ try:
|
|
|
+ with open(input_path, 'r') as f:
|
|
|
+ first_lines = [next(f) for _ in range(5)]
|
|
|
+ logger.error(f"PARSE_FILE DEBUG: First 5 lines of file:")
|
|
|
+ for i, line in enumerate(first_lines):
|
|
|
+ logger.error(f" Line {i}: {line.strip()}")
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f"PARSE_FILE DEBUG: Could not read file: {e}")
|
|
|
+
|
|
|
document = {
|
|
|
"meta": {
|
|
|
"type": "",
|
|
|
@@ -351,19 +366,30 @@ def read_file(
|
|
|
p = f"{Path(repo_path)}/{tree}/{filename}"
|
|
|
else:
|
|
|
p = f"{Path(repo_path)}/{filename}"
|
|
|
+
|
|
|
+ logger.error(f"READ_FILE DEBUG: Looking for file at path: {p}")
|
|
|
+ logger.error(f"READ_FILE DEBUG: tree={tree}, filename={filename}, ext={ext}")
|
|
|
|
|
|
if Path(p).is_dir():
|
|
|
file_path = f"{p}/index{ext}"
|
|
|
+ logger.error(f"READ_FILE DEBUG: Path is directory, trying: {file_path}")
|
|
|
|
|
|
if Path(file_path).is_file():
|
|
|
filepath = file_path
|
|
|
+ logger.error(f"READ_FILE DEBUG: Found directory index: {filepath}")
|
|
|
else:
|
|
|
+ logger.error(f"READ_FILE DEBUG: Directory index not found: {file_path}")
|
|
|
raise FileNotFoundError
|
|
|
|
|
|
elif Path(f"{p}{ext}").is_file():
|
|
|
- filepath = f"{p}{ext}"
|
|
|
+ filepath = f"{p}{ext}"
|
|
|
+ logger.error(f"READ_FILE DEBUG: Found file directly: {filepath}")
|
|
|
|
|
|
if filepath:
|
|
|
+ logger.error(f"READ_FILE DEBUG: Reading file: {filepath}")
|
|
|
+ logger.error(f"READ_FILE DEBUG: File exists: {Path(filepath).exists()}")
|
|
|
+ logger.error(f"READ_FILE DEBUG: File size: {Path(filepath).stat().st_size if Path(filepath).exists() else 'N/A'}")
|
|
|
+
|
|
|
# get file path relative to the content repo
|
|
|
# eg <path/to/repo/dir/file> => <dir>/<file>
|
|
|
filename = str(Path(filepath).relative_to(repo_path))
|
|
|
@@ -371,4 +397,5 @@ def read_file(
|
|
|
return doc
|
|
|
|
|
|
else:
|
|
|
+ logger.error(f"READ_FILE DEBUG: No file found at: {p}{ext}")
|
|
|
raise HTTPException(status_code=404, detail="Nothing was found here.")
|