Spaces:
Running
Running
add chmod
Browse files
infrastructure/database.py
CHANGED
|
@@ -99,7 +99,7 @@ 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, "
|
| 103 |
with open(test_file, "a", encoding="utf-8") as tf:
|
| 104 |
tf.write("ok")
|
| 105 |
_logger.info(f"Directory {path} is writable.")
|
|
@@ -115,7 +115,10 @@ def _init_chroma_client():
|
|
| 115 |
return chromadb.Client() # type: ignore
|
| 116 |
|
| 117 |
abs_path = os.path.abspath(cand)
|
|
|
|
| 118 |
os.makedirs(abs_path, exist_ok=True)
|
|
|
|
|
|
|
| 119 |
if not _dir_writeable(abs_path):
|
| 120 |
continue
|
| 121 |
|
|
@@ -126,7 +129,7 @@ def _init_chroma_client():
|
|
| 126 |
fpath = os.path.join(abs_path, fname)
|
| 127 |
if not os.access(fpath, os.W_OK):
|
| 128 |
try:
|
| 129 |
-
os.chmod(fpath,
|
| 130 |
except Exception:
|
| 131 |
pass
|
| 132 |
except Exception:
|
|
|
|
| 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.")
|
|
|
|
| 115 |
return chromadb.Client() # type: ignore
|
| 116 |
|
| 117 |
abs_path = os.path.abspath(cand)
|
| 118 |
+
_logger.info(f"Attempting Chroma PersistentClient at {abs_path}")
|
| 119 |
os.makedirs(abs_path, exist_ok=True)
|
| 120 |
+
_logger.info(f"Ensured directory exists: {abs_path}")
|
| 121 |
+
os.chmod(abs_path, 0o1411)
|
| 122 |
if not _dir_writeable(abs_path):
|
| 123 |
continue
|
| 124 |
|
|
|
|
| 129 |
fpath = os.path.join(abs_path, fname)
|
| 130 |
if not os.access(fpath, os.W_OK):
|
| 131 |
try:
|
| 132 |
+
os.chmod(path=fpath, mode=0o1411)
|
| 133 |
except Exception:
|
| 134 |
pass
|
| 135 |
except Exception:
|