File tree Expand file tree Collapse file tree 2 files changed +17
-18
lines changed
Expand file tree Collapse file tree 2 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -200,9 +200,11 @@ def new_session(self):
200200
201201 def upload (self , note_events ):
202202 browser = self .get_browser ()
203- if not browser .go_graph (settings .get ('ROAM_GRAPH' )):
204- # Failed to go to graph - return False to indicate failure
205- print ("Failed to access Roam graph. Will retry notes later." )
203+ in_graph = browser .go_graph (settings .get ('ROAM_GRAPH' ))
204+ if not in_graph
205+ print ("Failed to access Roam graph. Aborting upload." )
206+ browser .screenshot ('screenshot-go_graph-failure.png' )
207+ flush ()
206208 return False
207209
208210 time .sleep (0.5 )
@@ -240,6 +242,11 @@ def upload(self, note_events):
240242 else :
241243 parent_uid = self .session_uid
242244 block_uid = browser .create_child_block (parent_uid , text )
245+ if not block_uid :
246+ print ('create_child_block did not yield a block_uid. Aborting upload.' )
247+ browser .screenshot ('screenshot-create_child_block-failure.png' )
248+ flush ()
249+ return False
243250 self .last_note_uid = block_uid
244251 print (f'Inserted: "{ text } " at block (({ block_uid } ))' )
245252 if has_audio :
Original file line number Diff line number Diff line change @@ -94,25 +94,17 @@ def main():
9494 status .set (Status .UPLOADER_ACTIVE , True )
9595 # TODO(dbieber): Allow uploader to yield note events as it finishes them.
9696 # So that if it fails midway, we can still mark the completed events as done.
97- try :
98- upload_success = uploader .upload (note_events )
99- # For older uploaders that don't return a value, assume success
100- if upload_success is None :
101- upload_success = True
102- except Exception as e :
103- print (f"Error during upload: { e } " )
104- upload_success = False
105-
106- if upload_success :
97+ upload_successful = uploader .upload (note_events )
98+ if upload_successful :
10799 last_upload = time .time ()
108100 print ('Uploaded.' )
109- # Only commit note events if upload was successful
110- for note_event_bytes in note_event_bytes_list :
111- note_events_queue .commit (note_event_bytes )
112101 else :
113- print ('Upload failed. Will retry notes later .' )
114-
102+ print ('Upload unsuccessful .' )
103+
115104 status .set (Status .UPLOADER_ACTIVE , False )
105+ if upload_successful :
106+ for note_event_bytes in note_event_bytes_list :
107+ note_events_queue .commit (note_event_bytes )
116108
117109 if last_upload and time .time () - last_upload > 600 :
118110 # X minutes have passed since the last upload.
You can’t perform that action at this time.
0 commit comments