Socket
Socket
Sign inDemoInstall

@crawlee/utils

Package Overview
Dependencies
Maintainers
1
Versions
1179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crawlee/utils - npm Package Compare versions

Comparing version 3.0.0-alpha.49 to 3.0.0-alpha.50

9

internals/general.d.ts

@@ -46,11 +46,2 @@ /// <reference types="node" />

/**
* Cleans up the default local storage directories before the run starts:
* - local directory containing the default dataset;
* - all records from the default key-value store in the local directory, except for the "INPUT" key;
* - local directory containing the default request queue.
*
* @param [folder] The folder to clean up
*/
export declare function purgeLocalStorage(folder?: string): Promise<void>;
/**
* Gets parsed content type from response object

@@ -57,0 +48,0 @@ * @param response HTTP response object

38

internals/general.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseContentTypeFromResponse = exports.purgeLocalStorage = exports.snakeCaseToCamelCase = exports.sleep = exports.weightedAvg = exports.isDocker = exports.URL_WITH_COMMAS_REGEX = exports.URL_NO_COMMAS_REGEX = void 0;
exports.parseContentTypeFromResponse = exports.snakeCaseToCamelCase = exports.sleep = exports.weightedAvg = exports.isDocker = exports.URL_WITH_COMMAS_REGEX = exports.URL_NO_COMMAS_REGEX = void 0;
const tslib_1 = require("tslib");
const consts_1 = require("@apify/consts");
const content_type_1 = tslib_1.__importDefault(require("content-type"));

@@ -12,3 +11,2 @@ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));

const node_url_1 = require("node:url");
const fs_extra_1 = require("fs-extra");
const ow_1 = tslib_1.__importDefault(require("ow"));

@@ -96,36 +94,2 @@ /**

/**
* Cleans up the default local storage directories before the run starts:
* - local directory containing the default dataset;
* - all records from the default key-value store in the local directory, except for the "INPUT" key;
* - local directory containing the default request queue.
*
* @param [folder] The folder to clean up
*/
async function purgeLocalStorage(folder) {
// If the user did not provide a folder, try to get it from the env variables, or the default one
if (!folder)
folder = process.env[consts_1.ENV_VARS.LOCAL_STORAGE_DIR] || 'apify_storage';
const defaultDatasetPath = node_path_1.default.resolve(folder, consts_1.LOCAL_STORAGE_SUBDIRS.datasets, consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_DATASET_ID]);
await removeFiles(defaultDatasetPath);
const defaultKeyValueStorePath = node_path_1.default.resolve(folder, consts_1.LOCAL_STORAGE_SUBDIRS.keyValueStores, consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID]);
await removeFiles(defaultKeyValueStorePath);
const defaultRequestQueuePath = node_path_1.default.resolve(folder, consts_1.LOCAL_STORAGE_SUBDIRS.requestQueues, consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_REQUEST_QUEUE_ID]);
await removeFiles(defaultRequestQueuePath);
}
exports.purgeLocalStorage = purgeLocalStorage;
async function removeFiles(folder) {
const storagePathExists = await (0, fs_extra_1.pathExists)(folder);
if (storagePathExists) {
const direntNames = await promises_1.default.readdir(folder);
const deletePromises = [];
for (const direntName of direntNames) {
const fileName = node_path_1.default.join(folder, direntName);
if (!RegExp(consts_1.KEY_VALUE_STORE_KEYS.INPUT).test(fileName)) {
deletePromises.push(promises_1.default.rm(fileName, { recursive: true, force: true }));
}
}
await Promise.all(deletePromises);
}
}
/**
* Gets parsed content type from response object

@@ -132,0 +96,0 @@ * @param response HTTP response object

2

package.json
{
"name": "@crawlee/utils",
"version": "3.0.0-alpha.49",
"version": "3.0.0-alpha.50",
"description": "A set of shared utilities that can be used by crawlers",

@@ -5,0 +5,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc