phaethon-order commited on
Commit
45abfac
·
unverified ·
1 Parent(s): 9a94cda

add chmod

Browse files
Files changed (1) hide show
  1. infrastructure/database.py +7 -10
infrastructure/database.py CHANGED
@@ -7,16 +7,9 @@ from datetime import datetime, timezone
7
  from dataclasses import dataclass, field, fields
8
  from typing import List, Optional, Dict, Any
9
  import numpy as np
 
10
 
11
- from chromadb.utils import embedding_functions
12
-
13
- try:
14
- from infrastructure.logger import get_logger # reuse central logger if available
15
- _logger = get_logger()
16
- except Exception: # pragma: no cover - fallback minimal logger
17
- import logging as _logging
18
- _logging.basicConfig(level=_logging.INFO)
19
- _logger = _logging.getLogger("db")
20
 
21
  # ---------------------------------------------------------------------------
22
  # Versioning for corpus mechanics
@@ -39,6 +32,7 @@ def _setup_cache_dir():
39
  for cache_dir in cache_candidates:
40
  try:
41
  os.makedirs(cache_dir, exist_ok=True)
 
42
  # Test if writable
43
  test_file = os.path.join(cache_dir, ".write_test")
44
  with open(test_file, "w") as f:
@@ -99,8 +93,11 @@ def _init_chroma_client():
99
  def _dir_writeable(path: str) -> bool:
100
  try:
101
  os.makedirs(path, exist_ok=True)
 
 
 
102
  test_file = os.path.join(path, "write_test.txt")
103
- with open(test_file, "a", encoding="utf-8") as tf:
104
  tf.write("ok")
105
  _logger.info(f"Directory {path} is writable.")
106
  os.remove(test_file)
 
7
  from dataclasses import dataclass, field, fields
8
  from typing import List, Optional, Dict, Any
9
  import numpy as np
10
+ from infrastructure.logger import get_logger
11
 
12
+ _logger = get_logger()
 
 
 
 
 
 
 
 
13
 
14
  # ---------------------------------------------------------------------------
15
  # Versioning for corpus mechanics
 
32
  for cache_dir in cache_candidates:
33
  try:
34
  os.makedirs(cache_dir, exist_ok=True)
35
+ os.chmod(cache_dir, 0o1411)
36
  # Test if writable
37
  test_file = os.path.join(cache_dir, ".write_test")
38
  with open(test_file, "w") as f:
 
93
  def _dir_writeable(path: str) -> bool:
94
  try:
95
  os.makedirs(path, exist_ok=True)
96
+ _logger.info(f"Ensured directory exists: {path}")
97
+ os.chmod(path, 0o1411)
98
+ _logger.info(f"Set directory permissions to 1411: {path}")
99
  test_file = os.path.join(path, "write_test.txt")
100
+ with open(test_file, "x", encoding="utf-8") as tf:
101
  tf.write("ok")
102
  _logger.info(f"Directory {path} is writable.")
103
  os.remove(test_file)