Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
93f09f5a
Commit
93f09f5a
authored
Apr 24, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: unify aisbf.json path resolution via get_aisbf_config_path()
parent
da1607da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
43 deletions
+23
-43
main.py
main.py
+23
-43
No files found.
main.py
View file @
93f09f5a
...
@@ -154,6 +154,24 @@ def generate_self_signed_cert(cert_file: Path, key_file: Path):
...
@@ -154,6 +154,24 @@ def generate_self_signed_cert(cert_file: Path, key_file: Path):
logger
.
error
(
"cryptography library not installed. Install with: pip install cryptography"
)
logger
.
error
(
"cryptography library not installed. Install with: pip install cryptography"
)
raise
raise
def
get_aisbf_config_path
(
custom_config_dir
=
None
)
->
Path
:
"""Resolve aisbf.json using the canonical search order."""
candidates
=
[]
if
custom_config_dir
:
candidates
.
append
(
Path
(
custom_config_dir
)
/
'aisbf.json'
)
candidates
+=
[
Path
.
home
()
/
'.aisbf'
/
'aisbf.json'
,
Path
.
home
()
/
'.local'
/
'share'
/
'aisbf'
/
'aisbf.json'
,
Path
(
'/usr/local/share/aisbf/aisbf.json'
),
Path
(
'/usr/share/aisbf/aisbf.json'
),
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
,
]
for
p
in
candidates
:
if
p
.
exists
():
return
p
return
candidates
[
-
1
]
# fallback
def
load_server_config
(
custom_config_dir
=
None
):
def
load_server_config
(
custom_config_dir
=
None
):
"""Load server configuration from aisbf.json"""
"""Load server configuration from aisbf.json"""
# If custom config directory is provided, try it first
# If custom config directory is provided, try it first
...
@@ -804,18 +822,7 @@ def initialize_app(custom_config_dir=None):
...
@@ -804,18 +822,7 @@ def initialize_app(custom_config_dir=None):
server_config
=
load_server_config
(
custom_config_dir
)
server_config
=
load_server_config
(
custom_config_dir
)
# Load dashboard config
# Load dashboard config
aisbf_config_path
=
Path
.
home
()
/
'.aisbf'
/
'aisbf.json'
aisbf_config_path
=
get_aisbf_config_path
(
custom_config_dir
)
if
not
aisbf_config_path
.
exists
():
if
custom_config_dir
:
aisbf_config_path
=
Path
(
custom_config_dir
)
/
'aisbf.json'
else
:
# Try installed location first
installed_path
=
Path
(
__file__
)
.
parent
/
'aisbf.json'
if
installed_path
.
exists
():
aisbf_config_path
=
installed_path
else
:
# Fall back to config subdirectory
aisbf_config_path
=
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
if
aisbf_config_path
.
exists
():
if
aisbf_config_path
.
exists
():
with
open
(
aisbf_config_path
)
as
f
:
with
open
(
aisbf_config_path
)
as
f
:
...
@@ -5963,37 +5970,10 @@ async def dashboard_settings(request: Request):
...
@@ -5963,37 +5970,10 @@ async def dashboard_settings(request: Request):
if
auth_check
:
if
auth_check
:
return
auth_check
return
auth_check
# Load aisbf.json - check user config first, then installed locations
config_path
=
get_aisbf_config_path
()
config_path
=
Path
.
home
()
/
'.aisbf'
/
'aisbf.json'
if
not
config_path
.
exists
():
if
not
config_path
.
exists
():
# Try installed locations
raise
HTTPException
(
status_code
=
500
,
detail
=
"Configuration file not found"
)
installed_dirs
=
[
Path
.
home
()
/
'.local'
/
'share'
/
'aisbf'
,
Path
(
'/usr/share/aisbf'
),
Path
(
__file__
)
.
parent
,
# For source tree
]
source_path
=
None
for
installed_dir
in
installed_dirs
:
test_path
=
installed_dir
/
'aisbf.json'
if
test_path
.
exists
():
source_path
=
test_path
break
# Also check config subdirectory
test_path
=
installed_dir
/
'config'
/
'aisbf.json'
if
test_path
.
exists
():
source_path
=
test_path
break
if
source_path
:
# Copy to user config directory
config_path
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
import
shutil
shutil
.
copy2
(
source_path
,
config_path
)
logger
.
info
(
f
"Copied config from {source_path} to {config_path}"
)
else
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"Configuration file not found in any location"
)
with
open
(
config_path
)
as
f
:
with
open
(
config_path
)
as
f
:
aisbf_config
=
json
.
load
(
f
)
aisbf_config
=
json
.
load
(
f
)
...
@@ -6106,7 +6086,7 @@ async def dashboard_settings_save(
...
@@ -6106,7 +6086,7 @@ async def dashboard_settings_save(
return
auth_check
return
auth_check
# Load current config
# Load current config
config_path
=
Path
.
home
()
/
'.aisbf'
/
'aisbf.json'
config_path
=
get_aisbf_config_path
()
if
not
config_path
.
exists
():
if
not
config_path
.
exists
():
config_path
=
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
config_path
=
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
...
@@ -6311,7 +6291,7 @@ async def dashboard_test_smtp(request: Request):
...
@@ -6311,7 +6291,7 @@ async def dashboard_test_smtp(request: Request):
return
JSONResponse
({
"success"
:
False
,
"error"
:
"Test recipient email is required"
})
return
JSONResponse
({
"success"
:
False
,
"error"
:
"Test recipient email is required"
})
# Load the actual saved SMTP config from aisbf.json
# Load the actual saved SMTP config from aisbf.json
config_path
=
Path
.
home
()
/
'.aisbf'
/
'aisbf.json'
config_path
=
get_aisbf_config_path
()
if
not
config_path
.
exists
():
if
not
config_path
.
exists
():
config_path
=
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
config_path
=
Path
(
__file__
)
.
parent
/
'config'
/
'aisbf.json'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment