<commit_before><?php

/**
 * Responsible for creating sfSympalAsset records for any uploaded asset
 * 
 * @package     sfSympalAssetPlugin
 * @subpackage  util
 * @author      <NAME> <<EMAIL>>
 * @since       2010-03-06
 * @version     svn:$Id$ $Author$
 */
class sfSympalAssetSynchronizer
{
  private $_dispatcher;
  private $_path;

  public function __construct($dispatcher)
  {
    $this->_dispatcher = $dispatcher;
    $this->_path = sfConfig::get('sf_web_dir').sfSympalConfig::get('assets', 'root_dir', '/uploads');
  }

  public function run()
  {
    $this->synchronizeDirectory($this->_path);

    $dirs = sfFinder::type('dir')
      ->relative()
      ->prune('.*')
      ->discard('.*')
      ->relative()
      ->in($this->_path);
    foreach ($dirs as $dir)
    {
      $this->synchronizeDirectory($this->_path.'/'.$dir);
    }
  }

  public function synchronizeDirectory($dir)
  {
    $files = sfFinder::type('file')
      ->maxdepth(0)
      ->relative()
      ->in($dir);

    $path = str_replace($this->_path, null, $dir);

    $exists = Doctrine_Core::getTable('sfSympalAsset')->findByPath($path);
    $keys = array();
    foreach ($exists as $asset)
    {
      $keys[$asset->getName()] = $asset;
    }

    foreach ($files as $file)
    {
      if (!isset($keys[$file]))
      {
        $assetObject = sfSympalAssetToolkit::createAssetObject($path.'/'.$file);<commit_msg>[1.4][sfSympalPlugin][1.0] Removing extra ->relative() method call<commit_after><?php

/**
 * Responsible for creating sfSympalAsset records for any uploaded asset
 * 
 * @package     sfSympalAssetPlugin
 * @subpackage  util
 * @author      <NAME> <<EMAIL>>
 * @since       2010-03-06
 * @version     svn:$Id$ $Author$
 */
class sfSympalAssetSynchronizer
{
  private $_dispatcher;
  private $_path;

  public function __construct($dispatcher)
  {
    $this->_dispatcher = $dispatcher;
    $this->_path = sfConfig::get('sf_web_dir').sfSympalConfig::get('assets', 'root_dir', '/uploads');
  }

  public function run()
  {
    $this->synchronizeDirectory($this->_path);

    $dirs = sfFinder::type('dir')
      ->prune('.*')
      ->discard('.*')
      ->relative()
      ->in($this->_path);
    foreach ($dirs as $dir)
    {
      $this->synchronizeDirectory($this->_path.'/'.$dir);
    }
  }

  public function synchronizeDirectory($dir)
  {
    $files = sfFinder::type('file')
      ->maxdepth(0)
      ->relative()
      ->in($dir);

    $path = str_replace($this->_path, null, $dir);

    $exists = Doctrine_Core::getTable('sfSympalAsset')->findByPath($path);
    $keys = array();
    foreach ($exists as $asset)
    {
      $keys[$asset->getName()] = $asset;
    }

    foreach ($files as $file)
    {
      if (!isset($keys[$file]))
      {
        $assetObject = sfSympalAssetToolkit::createAssetObject($path.'/'.$file);
{'fraction_non_alphanumeric': 0.18181818181818182, 'fraction_numerical': 0.0078125, 'mean_word_length': 3.076700434153401, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117685', 'n_tokens_mistral': 947, 'n_tokens_neox': 923, 'n_words': 169}