HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/.nvm/versions/node/v22.3.0/lib/node_modules/chromium/cache.js
'use strict';
const path = require('path');
const fs = require('fs');
const cachedir = require('cachedir');
const config = require('./config');

/**
 * Retrieve a Chromium archive from filesystem cache.
 * @param {string} revision The Chromium revision to retrieve.
 * @returns {string} The path to the cached Chromium archive. Falsy if not found.
 */
function get(revision) {
    const cachePath = buildCachePath(revision);
    if (fs.existsSync(cachePath)) {
        return cachePath;
    }

    return '';
}

/**
 * Store a Chromium archive in filesystem cache for future use.
 * Has no effect if the user has not configured a cache location.
 * @param {string} revision The Chromium revision in the archive file.
 * @param {string} filePath The path to the Chromium archive file to store in cache.
 */
function put(revision, filePath) {
    const cachePath = buildCachePath(revision);
    if (cachePath && filePath) {
        try {
            fs.mkdirSync(path.dirname(cachePath), {recursive: true});
            fs.copyFileSync(filePath, cachePath);
        } catch (error) {
            // Don't die on cache fail
            console.error('Could not cache file', cachePath, error);
        }
    }
}

/**
 * Get the unique cache path for this revision, on this platform and architecture.
 * @param {string} revision The revision of this Chromium binary, essentially a unique cache key.
 * @returns {string} The cache path, or falsy if caching is not enabled.
 */
function buildCachePath(revision) {
    if (!revision || config.getEnvVar('NODE_CHROMIUM_CACHE_DISABLE').toLowerCase() === 'true') {
        return '';
    }

    const cachePath = config.getEnvVar('NODE_CHROMIUM_CACHE_PATH') || cachedir('node-chromium');
    return path.join(cachePath, `chromium-${revision}-${process.platform}-${process.arch}.zip`);
}

module.exports = {
    get,
    put
};