@@ -285,13 +285,17 @@ async def backup_channel(channel, last_message_id):
285285 """
286286 # Load last message as a starting point
287287 after = None
288- if last_message_id > 0 :
289- after = await channel .fetch_message (last_message_id )
288+ try :
289+ if last_message_id > 0 :
290+ after = await channel .fetch_message (last_message_id )
291+ except discord .errors .NotFound :
292+ print ('\t Latch-on restore point vanished on discord. Doing a full grab of the channel.' )
293+ pass
290294
291295 # download manifest from S3
292296 manifest_path , s3_manifest_path = get_manifest_path (channel .guild .id , channel .id )
293297
294- if is_s3_enabled ():
298+ if is_s3_enabled () and after is not None :
295299 try :
296300 S3_CLIENT .head_object (Bucket = s3_bucket (), Key = s3_manifest_path )
297301 S3_CLIENT .download_file (Bucket = s3_bucket (),
@@ -318,17 +322,19 @@ async def backup_channel(channel, last_message_id):
318322 write_to_storage (backup_msg )
319323
320324 after = messages [- 1 ]
325+ except discord .errors .NotFound :
326+ print ('\t Unable to find message to latch on.' )
321327 except nextcord .Forbidden :
322- print ('No permission to read channel. Check roles in discord!' )
328+ print ('\t No permission to read channel. Check roles in discord!' )
323329 # exit the function with no new location msg id
324330 return None
325331
326332 except Exception as e : # pylint: disable=broad-except
327333 logging .exception (e )
328334 if after is not None :
329- print ('Cant pull more messages - stopping here for now.' )
335+ print ('\t Cant pull more messages - stopping here for now.' )
330336 else :
331- print ('Failed channel pull - skipping' )
337+ print ('\t Failed channel pull - skipping' )
332338 return None
333339
334340 # Seal the manifest
@@ -342,7 +348,7 @@ async def backup_channel(channel, last_message_id):
342348 S3_CLIENT .upload_file (manifest_path , s3_bucket (), s3_manifest_path )
343349 S3_CLIENT .upload_file (manifest_seal_path , s3_bucket (), s3_manifest_seal_path )
344350 else :
345- print (f'No manifest for { channel .guild .id } - { channel .id } . Likly empty channel. Skipping S3 upload.' )
351+ print (f'\t No manifest for { channel .guild .id } - { channel .id } . Likely empty channel. Skipping S3 upload.' )
346352
347353 if after is None :
348354 return None
@@ -577,7 +583,9 @@ async def on_ready():
577583 print (f'Backing up Channel { channel .name } on { channel .guild .name } ' )
578584
579585 # Backup channels
586+ printf ('\t Retrieving last message Id' )
580587 last_msg_id = await get_last_message_id (channel )
588+ printf (f'\t Continue backup from last message Id: { last_msg_id } ' )
581589 new_last_msg_id = await backup_channel (channel , last_msg_id )
582590 if new_last_msg_id is not None :
583591 await set_last_message_id (channel , new_last_msg_id )
0 commit comments