Skip to content

Commit

Permalink
we write in the db only during the second send with the nested groups
Browse files Browse the repository at this point in the history
  • Loading branch information
sfonteneau committed Nov 16, 2024
1 parent 1cc54b4 commit 4dbea3d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions run_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,35 @@ def run_sync(force=False,from_db=False):
if [g for g in smb.dict_all_group_samba[entry]['groupMembers'] if g in dict_error]:
continue

if dry_run:
continue

for g in smb.dict_all_group_samba[entry]["groupMembers"]:
if g in list_group_create:
list_nested_group[entry] = None

if entry in list_nested_group
continue

if not dry_run:
if not last_data:
AzureObject.insert(sourceanchor=entry,object_type='group',last_data_send =json.dumps(smb.dict_all_group_samba[entry]),last_data_send_date = datetime.datetime.now()).execute()
else:
AzureObject.update(last_data_send =json.dumps(smb.dict_all_group_samba[entry]),last_data_send_date = datetime.datetime.now()).where(AzureObject.sourceanchor==entry).execute()

for g in smb.dict_all_group_samba[entry]["groupMembers"]:
if g in list_group_create:
list_nested_group[entry] = None

already_wait = False
if list_nested_group:
print('New group with nested detected wait 30s')
print('New group with nested detected wait 30s for send again')
time.sleep(30)
already_wait = True
for entry in list_nested_group:
try:
azure.send_obj_to_az(smb.dict_all_group_samba[entry])
last_data = AzureObject.select(AzureObject.last_data_send).where(AzureObject.sourceanchor==entry,AzureObject.object_type=='group').first()
if not last_data:
AzureObject.insert(sourceanchor=entry,object_type='group',last_data_send =json.dumps(smb.dict_all_group_samba[entry]),last_data_send_date = datetime.datetime.now()).execute()
else:
AzureObject.update(last_data_send =json.dumps(smb.dict_all_group_samba[entry]),last_data_send_date = datetime.datetime.now()).where(AzureObject.sourceanchor==entry).execute()
except:
write_log_json_data('error',{'sourceanchor':entry,'action':'send_group','traceback':traceback.format_exc()})
continue
Expand Down

0 comments on commit 4dbea3d

Please sign in to comment.