fix: look in share_dir/config/ for providers.json; fix find_config_file to check config/ subdir

parent c6f39ebc
......@@ -73,7 +73,7 @@ fi
mkdir -p "$LOG_DIR"
# Function to find the aisbf.json config file
# Checks user config first, then installed locations, then source tree
# Checks user config first, then installed locations (config/ subdir first, then root), then source tree
find_config_file() {
# Check user config first (~/.aisbf/aisbf.json)
if [ -f "$HOME/.aisbf/aisbf.json" ]; then
......@@ -81,22 +81,21 @@ find_config_file() {
return
fi
# Check installed locations
if [ -f "/usr/share/aisbf/aisbf.json" ]; then
echo "/usr/share/aisbf/aisbf.json"
return
fi
if [ -f "$HOME/.local/share/aisbf/aisbf.json" ]; then
echo "$HOME/.local/share/aisbf/aisbf.json"
return
fi
# Check source tree config
if [ -f "$SHARE_DIR/config/aisbf.json" ]; then
echo "$SHARE_DIR/config/aisbf.json"
# Check installed share locations — config/ subdir takes priority over root
for dir in \
"$SHARE_DIR/config" \
"$SHARE_DIR" \
"$HOME/.local/share/aisbf/config" \
"$HOME/.local/share/aisbf" \
"/usr/local/share/aisbf/config" \
"/usr/local/share/aisbf" \
"/usr/share/aisbf/config" \
"/usr/share/aisbf"; do
if [ -f "$dir/aisbf.json" ]; then
echo "$dir/aisbf.json"
return
fi
done
# Not found
echo ""
......
......@@ -73,7 +73,7 @@ fi
mkdir -p "$LOG_DIR"
# Function to find the aisbf.json config file
# Checks user config first, then installed locations, then source tree
# Checks user config first, then installed locations (config/ subdir first, then root), then source tree
find_config_file() {
# Check user config first (~/.aisbf/aisbf.json)
if [ -f "$HOME/.aisbf/aisbf.json" ]; then
......@@ -81,22 +81,21 @@ find_config_file() {
return
fi
# Check installed locations
if [ -f "/usr/share/aisbf/aisbf.json" ]; then
echo "/usr/share/aisbf/aisbf.json"
return
fi
if [ -f "$HOME/.local/share/aisbf/aisbf.json" ]; then
echo "$HOME/.local/share/aisbf/aisbf.json"
return
fi
# Check source tree config
if [ -f "$SHARE_DIR/config/aisbf.json" ]; then
echo "$SHARE_DIR/config/aisbf.json"
# Check installed share locations — config/ subdir takes priority over root
for dir in \
"$SHARE_DIR/config" \
"$SHARE_DIR" \
"$HOME/.local/share/aisbf/config" \
"$HOME/.local/share/aisbf" \
"/usr/local/share/aisbf/config" \
"/usr/local/share/aisbf" \
"/usr/share/aisbf/config" \
"/usr/share/aisbf"; do
if [ -f "$dir/aisbf.json" ]; then
echo "$dir/aisbf.json"
return
fi
done
# Not found
echo ""
......
......@@ -346,19 +346,18 @@ class Config:
if (self._custom_config_dir / 'providers.json').exists():
return self._custom_config_dir
# Try installed locations in order of preference
# 1. User-local installation (pip install --user)
# 2. System-wide installation (sudo pip install)
# 3. Alternative system location
installed_dirs = [
# Try installed locations in order of preference.
# Check both share_dir/config/ (current layout) and share_dir/ (legacy).
share_roots = [
Path.home() / '.local' / 'share' / 'aisbf',
Path('/usr/local/share/aisbf'),
Path('/usr/share/aisbf'),
]
for installed_dir in installed_dirs:
if installed_dir.exists() and (installed_dir / 'providers.json').exists():
return installed_dir
for root in share_roots:
for candidate in (root / 'config', root):
if candidate.exists() and (candidate / 'providers.json').exists():
return candidate
# Fallback to source tree config directory
# This is for development mode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment