lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.2k stars 483 forks source link

Recover downloads from suggested file name bug #3690

Closed shyba closed 1 year ago

shyba commented 1 year ago

Current release has a bug for new streams with suggested file name missing. When combined with save_files=True , they create lbry_download files on Downloads folder with missing mime type etc This is fixed on #3686 for new streams, but we lack a way to recover those that turned bad downloads.

Given: bad file downloaded from before #3686 (like the ones listed at https://github.com/lbryio/lbry-sdk/issues/3681) w/ lbry_download files generated from that bug lbry://@jimakudaio#9/Youtube-Google-Whistleblower-Reveals-A-Dangerous-Agenda!#0 is an example

When: using a fixed version after #3686 :

2022-10-17 15:05:11,428 ERROR    lbry.file.file_manager:257: Unexpected error downloading stream:                                                                                                                  
Traceback (most recent call last):                                                                                                                                                                                 
  File "/home/user/lbry/lbry-sdk/lbry/file/file_manager.py", line 217, in download_from_uri                                                                                                                        
    await stream.start(timeout, save_file)                                                                                                                                                                         
  File "/home/user/lbry/lbry-sdk/lbry/stream/managed_stream.py", line 177, in start                                                                                                                                
    self._file_name or sanitize_file_name(self.suggested_file_name)                                                                                                                                                
  File "/home/user/lbry/lbry-sdk/lbry/stream/managed_stream.py", line 91, in suggested_file_name                                                                                                                   
    self.stream_claim_info.claim.stream.source.name))                                                                                                                                                              
  File "/home/user/lbry/lbry-sdk/lbry/stream/descriptor.py", line 70, in sanitize_file_name                                                                                                                        
    file_name, ext = os.path.splitext(dirty_name)                                                                                                                                                                  
  File "/home/user/.pyenv/versions/3.7-dev/lib/python3.7/posixpath.py", line 122, in splitext                                                                                                                      
    p = os.fspath(p)                                                                                                                                                                                               
TypeError: expected str, bytes or os.PathLike object, not NoneType  

Expected: