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

parent c6f39ebc
...@@ -73,7 +73,7 @@ fi ...@@ -73,7 +73,7 @@ fi
mkdir -p "$LOG_DIR" mkdir -p "$LOG_DIR"
# Function to find the aisbf.json config file # 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() { find_config_file() {
# Check user config first (~/.aisbf/aisbf.json) # Check user config first (~/.aisbf/aisbf.json)
if [ -f "$HOME/.aisbf/aisbf.json" ]; then if [ -f "$HOME/.aisbf/aisbf.json" ]; then
...@@ -81,22 +81,21 @@ find_config_file() { ...@@ -81,22 +81,21 @@ find_config_file() {
return return
fi fi
# Check installed locations # Check installed share locations — config/ subdir takes priority over root
if [ -f "/usr/share/aisbf/aisbf.json" ]; then for dir in \
echo "/usr/share/aisbf/aisbf.json" "$SHARE_DIR/config" \
return "$SHARE_DIR" \
fi "$HOME/.local/share/aisbf/config" \
"$HOME/.local/share/aisbf" \
if [ -f "$HOME/.local/share/aisbf/aisbf.json" ]; then "/usr/local/share/aisbf/config" \
echo "$HOME/.local/share/aisbf/aisbf.json" "/usr/local/share/aisbf" \
return "/usr/share/aisbf/config" \
fi "/usr/share/aisbf"; do
if [ -f "$dir/aisbf.json" ]; then
# Check source tree config echo "$dir/aisbf.json"
if [ -f "$SHARE_DIR/config/aisbf.json" ]; then
echo "$SHARE_DIR/config/aisbf.json"
return return
fi fi
done
# Not found # Not found
echo "" echo ""
......
...@@ -73,7 +73,7 @@ fi ...@@ -73,7 +73,7 @@ fi
mkdir -p "$LOG_DIR" mkdir -p "$LOG_DIR"
# Function to find the aisbf.json config file # 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() { find_config_file() {
# Check user config first (~/.aisbf/aisbf.json) # Check user config first (~/.aisbf/aisbf.json)
if [ -f "$HOME/.aisbf/aisbf.json" ]; then if [ -f "$HOME/.aisbf/aisbf.json" ]; then
...@@ -81,22 +81,21 @@ find_config_file() { ...@@ -81,22 +81,21 @@ find_config_file() {
return return
fi fi
# Check installed locations # Check installed share locations — config/ subdir takes priority over root
if [ -f "/usr/share/aisbf/aisbf.json" ]; then for dir in \
echo "/usr/share/aisbf/aisbf.json" "$SHARE_DIR/config" \
return "$SHARE_DIR" \
fi "$HOME/.local/share/aisbf/config" \
"$HOME/.local/share/aisbf" \
if [ -f "$HOME/.local/share/aisbf/aisbf.json" ]; then "/usr/local/share/aisbf/config" \
echo "$HOME/.local/share/aisbf/aisbf.json" "/usr/local/share/aisbf" \
return "/usr/share/aisbf/config" \
fi "/usr/share/aisbf"; do
if [ -f "$dir/aisbf.json" ]; then
# Check source tree config echo "$dir/aisbf.json"
if [ -f "$SHARE_DIR/config/aisbf.json" ]; then
echo "$SHARE_DIR/config/aisbf.json"
return return
fi fi
done
# Not found # Not found
echo "" echo ""
......
...@@ -346,19 +346,18 @@ class Config: ...@@ -346,19 +346,18 @@ class Config:
if (self._custom_config_dir / 'providers.json').exists(): if (self._custom_config_dir / 'providers.json').exists():
return self._custom_config_dir return self._custom_config_dir
# Try installed locations in order of preference # Try installed locations in order of preference.
# 1. User-local installation (pip install --user) # Check both share_dir/config/ (current layout) and share_dir/ (legacy).
# 2. System-wide installation (sudo pip install) share_roots = [
# 3. Alternative system location
installed_dirs = [
Path.home() / '.local' / 'share' / 'aisbf', Path.home() / '.local' / 'share' / 'aisbf',
Path('/usr/local/share/aisbf'), Path('/usr/local/share/aisbf'),
Path('/usr/share/aisbf'), Path('/usr/share/aisbf'),
] ]
for installed_dir in installed_dirs: for root in share_roots:
if installed_dir.exists() and (installed_dir / 'providers.json').exists(): for candidate in (root / 'config', root):
return installed_dir if candidate.exists() and (candidate / 'providers.json').exists():
return candidate
# Fallback to source tree config directory # Fallback to source tree config directory
# This is for development mode # 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