#NEWLINE# def migrate_lbryfile_manager_db( old_db_dir , new_db_dir ) : #NEWLINE# #INDENT# old_db_path = os . path . join ( old_db_dir , 'lbryfiles.db' ) #NEWLINE# if ( not os . path . exists ( old_db_path ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# old_db = leveldb . LevelDB ( old_db_path ) #NEWLINE# new_db = sqlite3 . connect ( os . path . join ( c , 'lbryfile_info.db' ) ) #NEWLINE# c = new_db . cursor ( ) #NEWLINE# c . execute ( ( ( ( ( 'create table if not exists lbry_file_options (' + '    blob_data_rate real, ' ) + '    status text,' ) + '    stream_hash text,    foreign key(stream_hash) references lbry_files(stream_hash)' ) + ')' ) ) #NEWLINE# new_db . commit ( ) #NEWLINE# LBRYFILE_STATUS = 't' #NEWLINE# LBRYFILE_OPTIONS = 'o' #NEWLINE# c = new_db . cursor ( ) #NEWLINE# for ( k , v ) in old_db . RangeIter ( ) : #NEWLINE# #INDENT# ( key_type , stream_hash ) = json . loads ( k ) #NEWLINE# if ( key_type == LBRYFILE_STATUS ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# rate = json . loads ( old_db . Get ( json . dumps ( ( LBRYFILE_OPTIONS , stream_hash ) ) ) ) [ 0 ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# rate = None #NEWLINE# #UNINDENT# c . execute ( 'insert into lbry_file_options values (?, ?, ?)' , ( rate , v , stream_hash ) ) #NEWLINE# #UNINDENT# #UNINDENT# new_db . commit ( ) #NEWLINE# new_db . close ( )