Skip to content

Commit a4516d5

Browse files
dbieberclaude
andauthored
Fix issue with Roam uploader marking notes as uploaded when login fails (#114)
* Fix issue with Roam uploader marking notes as uploaded when login fails When 'Failed to go to graph. No retries left.' occurs, we now prevent notes from being marked as uploaded. The uploader now returns a success/failure status, and the runner only marks notes as committed if the upload succeeds. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Update Roam uploader to handle login failures gracefully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix syntax error in roam_uploader.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add return True to all other uploaders for consistency Make all uploader.upload() methods return a success value to be compatible with the changes in runner.py for handling upload failures. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c98b684 commit a4516d5

File tree

7 files changed

+29
-7
lines changed

7 files changed

+29
-7
lines changed

gonotego/uploader/email/email_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def upload(self, note_events):
3737
with open(DRAFT_FILENAME, 'a') as f:
3838
f.write(line + '\n')
3939
self.last_indent_level = self.indent_level
40+
return True
4041

4142
def handle_inactivity(self):
4243
self.end_session()

gonotego/uploader/ideaflow/ideaflow_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def upload(self, note_events):
105105
audio_url = blob_uploader.upload_blob(note_event.audio_filepath, client)
106106
text = f'{text} #unverified-transcription ({audio_url})'
107107
browser.insert_note(text)
108+
return True
108109

109110
def handle_inactivity(self):
110111
self.close_browser()

gonotego/uploader/mem/mem_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def upload(self, note_events):
3434
else:
3535
is_read = True
3636
upload_mem(text, is_read=is_read)
37+
return True
3738

3839
def handle_inactivity(self):
3940
pass

gonotego/uploader/notion/notion_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def upload(self, note_events):
8484
url = blob_uploader.upload_blob(note_event.audio_filepath, client)
8585
blocks.append(make_audio_block(url))
8686
append_notes(blocks, page_id=self.current_page_id)
87+
return True
8788

8889
def handle_inactivity(self):
8990
self.current_page_id = None

gonotego/uploader/remnote/remnote_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def upload(self, note_events):
4242
if note_event.audio_filepath and os.path.exists(note_event.audio_filepath):
4343
url = blob_uploader.upload_blob(note_event.audio_filepath, client)
4444
create_rem(url, edit_later=False, parent_id=rem_id)
45+
return True
4546

4647
def handle_inactivity(self):
4748
pass

gonotego/uploader/roam/roam_uploader.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ def new_session(self):
200200

201201
def upload(self, note_events):
202202
browser = self.get_browser()
203-
browser.go_graph(settings.get('ROAM_GRAPH'))
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()
208+
return False
209+
204210
time.sleep(0.5)
205211
browser.screenshot('screenshot-graph-later.png')
206212
browser.execute_helper_js()
@@ -236,6 +242,11 @@ def upload(self, note_events):
236242
else:
237243
parent_uid = self.session_uid
238244
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
239250
self.last_note_uid = block_uid
240251
print(f'Inserted: "{text}" at block (({block_uid}))')
241252
if has_audio:
@@ -246,6 +257,8 @@ def upload(self, note_events):
246257
browser.create_child_block(block_uid, embed_text)
247258

248259
flush()
260+
261+
return True
249262

250263
def handle_inactivity(self):
251264
self.end_session()

gonotego/uploader/runner.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +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-
uploader.upload(note_events)
98-
last_upload = time.time()
99-
print('Uploaded.')
100-
status.set(Status.UPLOADER_ACTIVE, False)
97+
upload_successful = uploader.upload(note_events)
98+
if upload_successful:
99+
last_upload = time.time()
100+
print('Uploaded.')
101+
else:
102+
print('Upload unsuccessful.')
101103

102-
for note_event_bytes in note_event_bytes_list:
103-
note_events_queue.commit(note_event_bytes)
104+
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)
104108

105109
if last_upload and time.time() - last_upload > 600:
106110
# X minutes have passed since the last upload.

0 commit comments

Comments
 (0)