<commit_before><?php

namespace luya\console\commands;

use admin\importers\StorageImporter;

/**
 * LUYA Admin Storage command.
 * 
 * @author <NAME> <<EMAIL>>
 */
class StorageController extends \luya\console\Command
{
    /**
     * Delete orphaned files, but requires user confirmation to ensure delete process.
     */
    public function actionCleanup()
    {
        $fileList = StorageImporter::getOrphanedFileList();

        if ($fileList === false) {
            return $this->outputError("Could not find the storage folder to clean up.");
        }
        
        if (count($fileList) > 0) {
            $this->output(print_r($fileList, true));
        }

        if (count($fileList) !== 0) {
            $success = true;
            if ($this->confirm("Do you want to delete " . count($fileList) . " files which are not referenced in the database any more?")) {
                foreach ($fileList as $file) {
                    if (is_file($file) && @unlink($file)) {
                        $this->outputSuccess($file . " successful deleted.");
                    } elseif (is_file($file)) {
                        $this->outputError($file . " could not be deleted!");
                        $success = false;
                    } else {
                        $this->outputError($file . " could not be found!");
                        $success = false;
                    }
                }
            }
            if ($success) {
                return $this->outputSuccess(count($fileList) . " files successful deleted.");
            }
            return $this->outputError("Cleanup could not be completed. Please look into error above.");
        }
        return $this->outputSuccess("No orphaned files found.");
    }
    
    /**
     * Create all thumbnails for filemanager preview. Otherwhise they are created on request load.
     */
    public function actionProcessThumbnails()
    {
        $response = Yii::$app->storage->processThumbnails();
        
        if ($response) {
            return $this->outputSuccess('Successful generated storage thumbnails.');
        }
        
        return $this->outputError('Error while creating the storage thumbnails.');
    }
}
<commit_msg>use Yii storage controller.<commit_after><?php

namespace luya\console\commands;

use Yii;
use admin\importers\StorageImporter;

/**
 * LUYA Admin Storage command.
 * 
 * @author <NAME> <<EMAIL>>
 */
class StorageController extends \luya\console\Command
{
    /**
     * Delete orphaned files, but requires user confirmation to ensure delete process.
     */
    public function actionCleanup()
    {
        $fileList = StorageImporter::getOrphanedFileList();

        if ($fileList === false) {
            return $this->outputError("Could not find the storage folder to clean up.");
        }
        
        if (count($fileList) > 0) {
            $this->output(print_r($fileList, true));
        }

        if (count($fileList) !== 0) {
            $success = true;
            if ($this->confirm("Do you want to delete " . count($fileList) . " files which are not referenced in the database any more?")) {
                foreach ($fileList as $file) {
                    if (is_file($file) && @unlink($file)) {
                        $this->outputSuccess($file . " successful deleted.");
                    } elseif (is_file($file)) {
                        $this->outputError($file . " could not be deleted!");
                        $success = false;
                    } else {
                        $this->outputError($file . " could not be found!");
                        $success = false;
                    }
                }
            }
            if ($success) {
                return $this->outputSuccess(count($fileList) . " files successful deleted.");
            }
            return $this->outputError("Cleanup could not be completed. Please look into error above.");
        }
        return $this->outputSuccess("No orphaned files found.");
    }
    
    /**
     * Create all thumbnails for filemanager preview. Otherwhise they are created on request load.
     */
    public function actionProcessThumbnails()
    {
        $response = Yii::$app->storage->processThumbnails();
        
        if ($response) {
            return $this->outputSuccess('Successful generated storage thumbnails.');
        }
        
        return $this->outputError('Error while creating the storage thumbnails.');
    }
}

{'fraction_non_alphanumeric': 0.12061648425284789, 'fraction_numerical': 0.0008934554389099843, 'mean_word_length': 1.7796399751707015, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '5778710', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1117, 'n_words': 313}