Skip to content

Commit 0d62357

Browse files
committed
Fix: Allow database update when file doesn't exist
The --update-database command should create the database file if it doesn't exist, but the current implementation raises an error before attempting the download. This fix changes the validation logic to only check if existing files are writeable, allowing the download logic to create the file and parent directories as needed. Fixes #2689
1 parent a18d184 commit 0d62357

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

intelmq/bots/experts/asn_lookup/expert.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ def update_database(cls, verbose=False):
123123
raise MissingDependencyError("pyasn")
124124

125125
for database_path in set(bots.values()):
126-
if not Path(database_path).is_file():
127-
raise ValueError('Database file does not exist or is not a file.')
128-
elif not os.access(database_path, os.W_OK):
129-
raise ValueError('Database file is not writeable.')
126+
database_file = Path(database_path)
127+
if database_file.is_file():
128+
# File exists, check if it's writeable
129+
if not os.access(database_path, os.W_OK):
130+
raise ValueError('Database file is not writeable.')
131+
# If file doesn't exist, the directory will be created later when downloading
130132

131133
try:
132134
if verbose:

0 commit comments

Comments
 (0)