#NEWLINE# def migrate_filenodes( ) : #NEWLINE# #INDENT# for node_settings in paginated ( osfstorage_model . OsfStorageNodeSettings ) : #NEWLINE# #INDENT# if ( node_settings . owner is None ) : #NEWLINE# #INDENT# logger . warning ( 'OsfStorageNodeSettings {} has no parent; skipping' . format ( node_settings . _id ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# logger . info ( 'Migrating files for {!r}' . format ( node_settings . owner ) ) #NEWLINE# listing = [ ] #NEWLINE# for filenode in osfstorage_model . OsfStorageFileNode . find ( Q ( 'node_settings' , 'eq' , node_settings . _id ) ) : #NEWLINE# #INDENT# logger . debug ( 'Migrating OsfStorageFileNode {}' . format ( filenode . _id ) ) #NEWLINE# versions = translate_versions ( filenode . versions ) #NEWLINE# if ( filenode . is_file and ( not filenode . node . is_deleted ) ) : #NEWLINE# #INDENT# if ( not filenode . versions ) : #NEWLINE# #INDENT# logger . warning ( 'File {!r} has no versions' . format ( filenode ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not versions ) : #NEWLINE# #INDENT# logger . warning ( '{!r} is a file with no translatable versions' . format ( filenode ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# new_node = models . StoredFileNode ( _id = filenode . _id , versions = versions , node = node_settings . owner , parent = ( None if ( not filenode . parent ) else filenode . parent . _id ) , is_file = ( filenode . kind == 'file' ) , provider = 'osfstorage' , name = filenode . name , last_touched = NOW ) #NEWLINE# new_node . wrapped ( ) . save ( ) #NEWLINE# listing . append ( new_node ) #NEWLINE# #UNINDENT# assert node_settings . get_root ( ) #NEWLINE# for x in listing : #NEWLINE# #INDENT# if x . to_storage ( ) [ 'parent' ] : #NEWLINE# #INDENT# assert x . parent , "{!r}'s parent {} does not exist" . format ( x . wrapped ( ) , x . to_storage ( ) [ 'parent' ] )