HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
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: /var/www/quadcode.com/node_modules/js-git/mixins/add-cache.js
"use strict";

module.exports = addCache;
function addCache(repo, cache) {
  var loadAs = repo.loadAs;
  if (loadAs) repo.loadAs = loadAsCached;
  var saveAs = repo.saveAs;
  if (saveAs) repo.saveAs = saveAsCached;
  var createTree = repo.createTree;
  if (createTree) repo.createTree = createTreeCached;

  function loadAsCached(type, hash, callback) {
    // Next check in disk cache...
    cache.loadAs(type, hash, onCacheLoad);

    function onCacheLoad(err, value) {
      if (err) return callback(err);
      // ...and return if it's there.
      if (value !== undefined) {
        return callback(null, value, hash);
      }

      // Otherwise load from real data source...
      loadAs.call(repo, type, hash, onLoad);
    }

    function onLoad(err, value) {
      if (value === undefined) return callback(err);

      // Store it on disk too...
      // Force the hash to prevent mismatches.
      cache.saveAs(type, value, onSave, hash);

      function onSave(err) {
        if (err) return callback(err);
        // Finally return the value to caller.
        callback(null, value, hash);
      }
    }
  }

  function saveAsCached(type, value, callback) {
    saveAs.call(repo, type, value, onSave);

    function onSave(err, hash) {
      if (err) return callback(err);
      // Store in disk, forcing hash to match.
      cache.saveAs(type, value, callback, hash);
    }
  }

  function createTreeCached(entries, callback) {
    createTree.call(repo, entries, onTree);

    function onTree(err, hash, tree) {
      if (err) return callback(err);
      cache.saveAs("tree", tree, callback, hash);
    }
  }

}