Skip to content

Commit

Permalink
distinguish different types of CDE errors
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Mar 1, 2024
1 parent 6660215 commit fc10596
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 56 deletions.
53 changes: 29 additions & 24 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
CD_OK_ID = 0
CD_INDEX_ID = 1
CD_DATA_ID = 2
CD_ABORTED_ID = 3
CD_EMPTY_ID = 4

def get_dev_labes_dict():
lsblk = subprocess_run(['lsblk','-fJ'],capture_output = True,text = True)
Expand Down Expand Up @@ -637,6 +639,8 @@ def extract_customdata(self,print_func,abort_list,threads=0):

CD_OK_ID_loc = CD_OK_ID
CD_DATA_ID_loc = CD_DATA_ID
CD_ABORTED_ID_loc = CD_ABORTED_ID
CD_EMPTY_ID_loc = CD_EMPTY_ID

all_threads_data_list={}
all_threads_files_cde_errors_quant = {}
Expand Down Expand Up @@ -668,6 +672,8 @@ def threaded_cde(timeout_semi_list,thread_index,thread_data_list,cde_errors_quan

self_killed[thread_index]=False

empty=False

time_start = perf_counter_loc()
if abort_list[0] : #wszystko
returncode=200
Expand Down Expand Up @@ -718,6 +724,7 @@ def threaded_cde(timeout_semi_list,thread_index,thread_data_list,cde_errors_quan
if not output:
output = 'No output collected.'
returncode=203
empty=True

#####################################

Expand All @@ -736,7 +743,9 @@ def threaded_cde(timeout_semi_list,thread_index,thread_data_list,cde_errors_quan

new_elem={
CD_OK_ID_loc:bool(returncode==0 and not self_killed[thread_index] and not aborted),
CD_DATA_ID_loc:(rule_nr,returncode,output)
CD_DATA_ID_loc:(rule_nr,returncode,output),
CD_ABORTED_ID_loc:aborted,
CD_EMPTY_ID_loc:empty
}

scan_like_list.append(new_elem) #dostep z wielu watkow
Expand Down Expand Up @@ -820,7 +829,6 @@ def threaded_cde(timeout_semi_list,thread_index,thread_data_list,cde_errors_quan
try:
used_cd_index = customdata_helper[cd_field]
new_elem[CD_INDEX_ID_loc]=used_cd_index
customdata_stats_refs[rule_nr]+=1
except:
customdata_helper[cd_field] = new_elem[CD_INDEX_ID_loc] = cd_index
cd_index+=1
Expand All @@ -829,7 +837,8 @@ def threaded_cde(timeout_semi_list,thread_index,thread_data_list,cde_errors_quan

customdata_stats_size[rule_nr]+=asizeof(cd_field)
customdata_stats_uniq[rule_nr]+=1
customdata_stats_refs[rule_nr]+=1

customdata_stats_refs[rule_nr]+=1


print_func( ('info','Custom data post-processing finished.'),True)
Expand Down Expand Up @@ -906,7 +915,8 @@ def tupelize_rec(self,scan_like_data,results_queue_put):
except:
has_cd = False
cd_ok = False
has_crc = False
cd_aborted = False
cd_empty = False
else:
#if 'cd_ok' in info_dict:
if CD_OK_ID in info_dict:
Expand All @@ -917,14 +927,17 @@ def tupelize_rec(self,scan_like_data,results_queue_put):
cd_ok = False
has_cd = False

#if 'crc_val' in info_dict:
# crc_val = info_dict['crc_val']
# has_crc = True
#else:
# has_crc = False
has_crc = False
if CD_ABORTED_ID in info_dict:
cd_aborted = info_dict[CD_ABORTED_ID]
else:
cd_aborted = False

code_new = LUT_encode_loc[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,False,False) ]
if CD_EMPTY_ID in info_dict:
cd_empty = info_dict[CD_EMPTY_ID]
else:
cd_empty = False

code_new = LUT_encode_loc[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,cd_aborted,cd_empty,False) ]

sub_list_elem=[entry_name_index,code_new,size,mtime]

Expand All @@ -934,8 +947,6 @@ def tupelize_rec(self,scan_like_data,results_queue_put):
if has_cd: #only files
self.header.references_cd+=1
sub_list_elem.append( cd_index )
if has_crc: #only files
sub_list_elem.append( crc_val )

sub_list.append( tuple(sub_list_elem) )

Expand All @@ -956,12 +967,11 @@ def pack_data(self,results_queue_put):
has_cd = False
has_files = True
cd_ok = False
has_crc = False

self.header.references_names=0
self.header.references_cd=0

code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,False,False) ]
code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,False,False,False) ]
self.filestructure = ('',code,size,mtime,self.tupelize_rec(self.scan_data,results_queue_put))

self.header.items_names=len(self.filenames)
Expand All @@ -975,12 +985,12 @@ def remove_cd_rec(self,tuple_like_data):

self_remove_cd_rec = self.remove_cd_rec

is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,aux1,aux2 = LUT_decode_loc[tuple_like_data[1]]
is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,cd_aborted,cd_empty,aux2 = LUT_decode_loc[tuple_like_data[1]]

has_cd=False
cd_ok=False

code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,aux1,aux2) ]
code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,cd_aborted,cd_empty,aux2) ]

new_list = [tuple_like_data[0],code,tuple_like_data[2],tuple_like_data[3]]

Expand Down Expand Up @@ -1058,7 +1068,7 @@ def find_items(self,

name = filenames_loc[name_nr]

is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,aux1,aux2 = LUT_decode_loc[code]
is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,cd_aborted,cd_empty,aux2 = LUT_decode_loc[code]

elem_index=4
if has_files:
Expand All @@ -1071,9 +1081,6 @@ def find_items(self,
cd_nr = data_entry[elem_index]
elem_index+=1

#if has_crc:
# crc = data_entry[elem_index]

next_level = parent_path_components + [name]
if name_search_kind_is_error:
if size>-1:
Expand Down Expand Up @@ -2004,16 +2011,14 @@ def import_records_wii_do(self,compr,postfix,label,quant_files,quant_folders,fil
has_cd = bool(new_record.customdata)
has_files = True
cd_ok = False
has_crc = False


new_record.header.references_names=0
new_record.header.references_cd=0

sub_size,sub_quant,sub_folders_quant = new_record.sld_recalc_rec(scan_like_data)
#print('ccc',sub_size,sub_quant,sub_folders_quant,flush=True)

code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,has_crc,False,False) ]
code = LUT_encode[ (is_dir,is_file,is_symlink,is_bind,has_cd,has_files,cd_ok,False,False,False) ]

new_record.header.sum_size = sub_size
new_record.header.quant_files = sub_quant
Expand Down
Loading

0 comments on commit fc10596

Please sign in to comment.