Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
fix(MemoryStorage): handle EXDEV errors when purging storages (#1932)
Vlad Frangue6560507243f
diff --git a/packages/memory-storage/src/memory-storage.ts b/packages/memory-storage/src/memory-storage.tsindex 81a446635..9358fa348 100644--- a/packages/memory-storage/src/memory-storage.ts+++ b/packages/memory-storage/src/memory-storage.ts@@ -2,9 +2,8 @@import type * as storage from '@crawlee/types';import type { Dictionary } from '@crawlee/types';import { s } from '@sapphire/shapeshift';-import { ensureDirSync, pathExistsSync } from 'fs-extra';-import { renameSync } from 'node:fs';-import { rm, rename, readdir } from 'node:fs/promises';+import { ensureDirSync, move, moveSync, pathExistsSync } from 'fs-extra';+import { rm, readdir } from 'node:fs/promises';import { resolve } from 'node:path';import { DatasetClient } from './resource-clients/dataset';import { DatasetCollectionClient } from './resource-clients/dataset-collection';@@ -206,7 +205,7 @@ export class MemoryStorage implements storage.StorageClient {const tempFilePath = resolve(temporaryPath, entity);try {- renameSync(originalFilePath, tempFilePath);+ moveSync(originalFilePath, tempFilePath);} catch {// Ignore}@@ -219,7 +218,7 @@ export class MemoryStorage implements storage.StorageClient {while (!done) {try {- renameSync(folder, tempPathForOldFolder);+ moveSync(folder, tempPathForOldFolder);done = true;} catch {tempPathForOldFolder = resolve(folder, `../__OLD_DEFAULT_${++counter}__`);@@ -227,7 +226,7 @@ export class MemoryStorage implements storage.StorageClient {}// Replace the temporary folder with the original folder- renameSync(temporaryPath, folder);+ moveSync(temporaryPath, folder);// Remove the old folderreturn async () => (await this.batchRemoveFiles(tempPathForOldFolder))();@@ -244,7 +243,7 @@ export class MemoryStorage implements storage.StorageClient {try {// Rename the old folder to the new one to allow background deletions- await rename(folder, temporaryFolder);+ await move(folder, temporaryFolder);} catch {// Folder exists already, try again with an incremented counterreturn this.batchRemoveFiles(folder, ++counter);