@@ -430,6 +430,8 @@ def get_analysis_results():
430430
431431
432432def save_analysis_results (t_cnt ):
433+ if not validate_history_file ():
434+ return ("Not available" ,) * 6
433435 with open (HUMBLE_FILES [0 ], 'a+' , encoding = 'utf8' ) as all_analysis :
434436 all_analysis .seek (0 )
435437 url_ln = [line for line in all_analysis if URL in line ]
@@ -468,6 +470,8 @@ def compare_analysis_results(*analysis_totals, en_cnt, m_cnt, f_cnt, i_cnt,
468470 e_cnt , t_cnt ):
469471 if analysis_totals [0 ] == "First" :
470472 return [get_detail ('[first_analysis]' , replace = True )] * 6
473+ elif analysis_totals [0 ] == "Not available" :
474+ return [get_detail ('[notaval_analysis]' , replace = True )] * 6
471475 current = [int (val ) for val in analysis_totals ]
472476 differences = [en_cnt , m_cnt , f_cnt , i_cnt [0 ], e_cnt , t_cnt ]
473477 return [get_detail ('[no_changes]' , replace = True ) if (d - c ) == 0
@@ -1477,23 +1481,37 @@ def check_input_traversal(user_input):
14771481 sys .exit ()
14781482
14791483
1480- def check_path_permissions (output_path ):
1484+ def validate_path (output_path ):
1485+ # Validates if there are errors with the supplied path.
14811486 try :
1482- open (path .join (output_path , HUMBLE_FILES [1 ]), 'w' )
1483- except PermissionError :
1484- print (f"\n { get_detail ('[args_nowr]' , replace = True )} \
1485- ('{ output_path } ')" )
1487+ with open (path .join (output_path , HUMBLE_FILES [1 ]), 'w' ):
1488+ pass
1489+ except OSError as e :
1490+ print (f"\n { get_detail ('[args_pathe]' , replace = True )} '{ output_path } ' \
1491+ ({ e .strerror } )" )
14861492 sys .exit ()
14871493 else :
14881494 remove (path .join (output_path , HUMBLE_FILES [1 ]))
14891495
14901496
1497+ def validate_history_file ():
1498+ # Validates if the analysis history file (analysis_h.txt) can be created in
1499+ # the current path, avoiding errors in restricted filesystems such as
1500+ # those used by AI like 'gemini-cli'.
1501+ try :
1502+ with open (path .join (OS_PATH , HUMBLE_FILES [0 ]), 'a+' , encoding = 'utf8' ):
1503+ pass
1504+ except OSError :
1505+ return False
1506+ return True
1507+
1508+
14911509def check_output_path (args , output_path ):
14921510 check_input_traversal (args .output_path )
14931511 if args .output is None :
14941512 print_error_detail ('[args_nooutputfmt]' )
14951513 elif path .exists (output_path ):
1496- check_path_permissions (output_path )
1514+ validate_path (output_path )
14971515 else :
14981516 print (f"\n { get_detail ('[args_noexportpath]' , replace = True )} \
14991517 ('{ output_path } ')" )
0 commit comments