def _clear_old_remotes():
 bp_ = os.path.join(__opts__['cachedir'], 'hgfs')
 try:
  cachedir_ls = os.listdir(bp_)
 except OSError:
  cachedir_ls = []
 repos = init()
 for repo in repos:
  try:
   cachedir_ls.remove(repo['hash'])
  except ValueError:
   pass
 to_remove = []
 for item in cachedir_ls:
  if (item in ('hash', 'refs')):
   continue
  path = os.path.join(bp_, item)
  if os.path.isdir(path):
   to_remove.append(path)
 failed = []
 if to_remove:
  for rdir in to_remove:
   try:
    shutil.rmtree(rdir)
   except OSError as exc:
    log.error('Unable to remove old hgfs remote cachedir {0}: {1}'.format(rdir, exc))
    failed.append(rdir)
   else:
    log.debug('hgfs removed old cachedir {0}'.format(rdir))
 for fdir in failed:
  to_remove.remove(fdir)
 return (bool(to_remove), repos)

def _clear_old_remotes ( ) : bp_ = os . path . join ( __opts__ [ 'cachedir' ] , 'hgfs' ) try : cachedir_ls = os . listdir ( bp_ ) except OSError : cachedir_ls = [ ] repos = init ( ) for repo in repos : try : cachedir_ls . remove ( repo [ 'hash' ] ) except ValueError : pass to_remove = [ ] for item in cachedir_ls : if ( item in ( 'hash' , 'refs' ) ) : continue path = os . path . join ( bp_ , item ) if os . path . isdir ( path ) : to_remove . append ( path ) failed = [ ] if to_remove : for rdir in to_remove : try : shutil . rmtree ( rdir ) except OSError as exc : log . error ( 'Unable to remove old hgfs remote cachedir {0}: {1}' . format ( rdir , exc ) ) failed . append ( rdir ) else : log . debug ( 'hgfs removed old cachedir {0}' . format ( rdir ) ) for fdir in failed : to_remove . remove ( fdir ) return ( bool ( to_remove ) , repos )
remove cache directories for remotes no longer configured .