<commit_before>import _ from 'lodash';
import path from 'path';
import url from 'url';
import logger from './logger';
import { tempDir, fs, util, zip, net, timing } from '@appium/support';
import LRU from 'lru-cache';
import AsyncLock from 'async-lock';
import axios from 'axios';

const IPA_EXT = '.ipa';
const ZIP_EXTS = ['.zip', IPA_EXT];
const ZIP_MIME_TYPES = [
  'application/zip',
  'application/x-zip-compressed',
  'multipart/x-zip',
];
const CACHED_APPS_MAX_AGE = 1000 * 60 * 60 * 24; // ms
const MAX_CACHED_APPS = 1024;
const APPLICATIONS_CACHE = new LRU({
  max: MAX_CACHED_APPS,
  ttl: CACHED_APPS_MAX_AGE, // expire after 24 hours
  updateAgeOnGet: true,
  dispose: (app, {fullPath}) => {
    logger.info(`The application '${app}' cached at '${fullPath}' has ` +
      `expired after ${CACHED_APPS_MAX_AGE}ms`);
    if (fullPath) {
      fs.rimraf(fullPath);
    }
  },
  noDisposeOnSet: true,
});
const APPLICATIONS_CACHE_GUARD = new AsyncLock();
const SANITIZE_REPLACEMENT = '-';
const DEFAULT_BASENAME = 'appium-app';
const APP_DOWNLOAD_TIMEOUT_MS = 120 * 1000;

process.on('exit', () => {
  if (APPLICATIONS_CACHE.itemCount === 0) {
    return;
  }

  const appPaths = [...APPLICATIONS_CACHE.values()]
    .map(({fullPath}) => fullPath);
  logger.debug(`Performing cleanup of ${appPaths.length} cached ` +
    util.pluralize('application', appPaths.length));
  for (const appPath of appPaths) {
    try {
      // Asynchronous calls are not supported in onExit handler
      fs.rimrafSync(appPath);
    } catch (e) {
      logger.warn(e.message);
    }
  }
});


async function retrieveHeaders (link) {
  try {
    return (await axios({
      url: link,
      method: 'HEAD',
      timeout: 5000,
    })).headers;
  } catch (e) {
    logger.info(`Cannot send HEAD request to '${link}'. Original error: ${e.message}`);
  }<commit_msg>fix: Update property name after lru-cache package bump (#16446)<commit_after>import _ from 'lodash';
import path from 'path';
import url from 'url';
import logger from './logger';
import { tempDir, fs, util, zip, net, timing } from '@appium/support';
import LRU from 'lru-cache';
import AsyncLock from 'async-lock';
import axios from 'axios';

const IPA_EXT = '.ipa';
const ZIP_EXTS = ['.zip', IPA_EXT];
const ZIP_MIME_TYPES = [
  'application/zip',
  'application/x-zip-compressed',
  'multipart/x-zip',
];
const CACHED_APPS_MAX_AGE = 1000 * 60 * 60 * 24; // ms
const MAX_CACHED_APPS = 1024;
const APPLICATIONS_CACHE = new LRU({
  max: MAX_CACHED_APPS,
  ttl: CACHED_APPS_MAX_AGE, // expire after 24 hours
  updateAgeOnGet: true,
  dispose: (app, {fullPath}) => {
    logger.info(`The application '${app}' cached at '${fullPath}' has ` +
      `expired after ${CACHED_APPS_MAX_AGE}ms`);
    if (fullPath) {
      fs.rimraf(fullPath);
    }
  },
  noDisposeOnSet: true,
});
const APPLICATIONS_CACHE_GUARD = new AsyncLock();
const SANITIZE_REPLACEMENT = '-';
const DEFAULT_BASENAME = 'appium-app';
const APP_DOWNLOAD_TIMEOUT_MS = 120 * 1000;

process.on('exit', () => {
  if (APPLICATIONS_CACHE.size === 0) {
    return;
  }

  const appPaths = [...APPLICATIONS_CACHE.values()]
    .map(({fullPath}) => fullPath);
  logger.debug(`Performing cleanup of ${appPaths.length} cached ` +
    util.pluralize('application', appPaths.length));
  for (const appPath of appPaths) {
    try {
      // Asynchronous calls are not supported in onExit handler
      fs.rimrafSync(appPath);
    } catch (e) {
      logger.warn(e.message);
    }
  }
});


async function retrieveHeaders (link) {
  try {
    return (await axios({
      url: link,
      method: 'HEAD',
      timeout: 5000,
    })).headers;
  } catch (e) {
    logger.info(`Cannot send HEAD request to '${link}'. Original error: ${e.message}`);
  }
{'fraction_non_alphanumeric': 0.14918601547904992, 'fraction_numerical': 0.016279690419001867, 'mean_word_length': 3.6967418546365916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6193761', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1314, 'n_words': 336}