def delete_orphaned_thumbs():
 documents_path = os.path.join(settings.MEDIA_ROOT, 'thumbs')
 for filename in os.listdir(documents_path):
  fn = os.path.join(documents_path, filename)
  model = filename.split('-')[0]
  uuid = filename.replace(model, '').replace('-thumb.png', '')[1:]
  if (ResourceBase.objects.filter(uuid=uuid).count() == 0):
   print ('Removing orphan thumb %s' % fn)
   try:
    os.remove(fn)
   except OSError:
    print ('Could not delete file %s' % fn)

def delete_orphaned_thumbs ( ) : documents_path = os . path . join ( settings . MEDIA_ROOT , 'thumbs' ) for filename in os . listdir ( documents_path ) : fn = os . path . join ( documents_path , filename ) model = filename . split ( '-' ) [ 0 ] uuid = filename . replace ( model , '' ) . replace ( '-thumb.png' , '' ) [ 1 : ] if ( ResourceBase . objects . filter ( uuid = uuid ) . count ( ) == 0 ) : print ( 'Removing orphan thumb %s' % fn ) try : os . remove ( fn ) except OSError : print ( 'Could not delete file %s' % fn )
deletes orphaned thumbnails .