@crawlee/fs-storage 4.0.0-beta.134 → 4.0.0-beta.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/file-system-storage.d.ts +0 -6
- package/file-system-storage.js +13 -13
- package/package.json +4 -4
package/file-system-storage.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type * as storage from '@crawlee/types';
|
|
2
2
|
import type { CrawleeLogger } from '@crawlee/types';
|
|
3
|
-
import { DatasetBackend } from './resource-clients/dataset.js';
|
|
4
|
-
import { KeyValueStoreBackend } from './resource-clients/key-value-store.js';
|
|
5
|
-
import { RequestQueueBackend } from './resource-clients/request-queue.js';
|
|
6
3
|
export interface FileSystemStorageOptions {
|
|
7
4
|
/**
|
|
8
5
|
* Path to directory where the data will be saved.
|
|
@@ -45,9 +42,6 @@ export declare class FileSystemStorageBackend implements storage.StorageBackend
|
|
|
45
42
|
readonly requestQueuesDirectory: string;
|
|
46
43
|
readonly logger?: CrawleeLogger;
|
|
47
44
|
readonly requestQueueAccess: 'single' | 'shared';
|
|
48
|
-
readonly keyValueStoreBackendCache: KeyValueStoreBackend[];
|
|
49
|
-
readonly datasetBackendCache: DatasetBackend[];
|
|
50
|
-
readonly requestQueueBackendCache: RequestQueueBackend[];
|
|
51
45
|
constructor(options: FileSystemStorageOptions);
|
|
52
46
|
/**
|
|
53
47
|
* Return a cache key that includes the resolved storage directory, so that two
|
package/file-system-storage.js
CHANGED
|
@@ -38,9 +38,9 @@ export class FileSystemStorageBackend {
|
|
|
38
38
|
requestQueuesDirectory;
|
|
39
39
|
logger;
|
|
40
40
|
requestQueueAccess;
|
|
41
|
-
keyValueStoreBackendCache = [];
|
|
42
|
-
datasetBackendCache = [];
|
|
43
|
-
requestQueueBackendCache = [];
|
|
41
|
+
#keyValueStoreBackendCache = [];
|
|
42
|
+
#datasetBackendCache = [];
|
|
43
|
+
#requestQueueBackendCache = [];
|
|
44
44
|
constructor(options) {
|
|
45
45
|
const { logger, requestQueueAccess, localDataDirectory } = parseArgument(options, fileSystemStorageOptionsSchema);
|
|
46
46
|
this.logger = logger;
|
|
@@ -73,7 +73,7 @@ export class FileSystemStorageBackend {
|
|
|
73
73
|
}
|
|
74
74
|
async createDatasetBackend(options = {}) {
|
|
75
75
|
const { id, name, alias, cacheKey } = FileSystemStorageBackend.#resolveStorageKey(options);
|
|
76
|
-
const found = this
|
|
76
|
+
const found = this.#datasetBackendCache.find((store) => store.id === cacheKey ||
|
|
77
77
|
store.name?.toLowerCase() === cacheKey.toLowerCase() ||
|
|
78
78
|
store.cacheKey.toLowerCase() === cacheKey.toLowerCase());
|
|
79
79
|
if (found) {
|
|
@@ -86,12 +86,12 @@ export class FileSystemStorageBackend {
|
|
|
86
86
|
nativeBackend,
|
|
87
87
|
logger: this.logger,
|
|
88
88
|
});
|
|
89
|
-
this
|
|
89
|
+
this.#datasetBackendCache.push(newStore);
|
|
90
90
|
return newStore;
|
|
91
91
|
}
|
|
92
92
|
async createKeyValueStoreBackend(options = {}) {
|
|
93
93
|
const { id, name, alias, cacheKey } = FileSystemStorageBackend.#resolveStorageKey(options);
|
|
94
|
-
const found = this
|
|
94
|
+
const found = this.#keyValueStoreBackendCache.find((store) => store.id === cacheKey ||
|
|
95
95
|
store.name?.toLowerCase() === cacheKey.toLowerCase() ||
|
|
96
96
|
store.cacheKey.toLowerCase() === cacheKey.toLowerCase());
|
|
97
97
|
if (found) {
|
|
@@ -104,12 +104,12 @@ export class FileSystemStorageBackend {
|
|
|
104
104
|
nativeBackend,
|
|
105
105
|
logger: this.logger,
|
|
106
106
|
});
|
|
107
|
-
this
|
|
107
|
+
this.#keyValueStoreBackendCache.push(newStore);
|
|
108
108
|
return newStore;
|
|
109
109
|
}
|
|
110
110
|
async createRequestQueueBackend(options = {}) {
|
|
111
111
|
const { id, name, alias, cacheKey } = FileSystemStorageBackend.#resolveStorageKey(options);
|
|
112
|
-
const found = this
|
|
112
|
+
const found = this.#requestQueueBackendCache.find((queue) => queue.id === cacheKey ||
|
|
113
113
|
queue.name?.toLowerCase() === cacheKey.toLowerCase() ||
|
|
114
114
|
queue.cacheKey.toLowerCase() === cacheKey.toLowerCase());
|
|
115
115
|
if (found) {
|
|
@@ -124,7 +124,7 @@ export class FileSystemStorageBackend {
|
|
|
124
124
|
nativeBackend,
|
|
125
125
|
logger: this.logger,
|
|
126
126
|
});
|
|
127
|
-
this
|
|
127
|
+
this.#requestQueueBackendCache.push(newStore);
|
|
128
128
|
return newStore;
|
|
129
129
|
}
|
|
130
130
|
async storageExists(id, type) {
|
|
@@ -132,15 +132,15 @@ export class FileSystemStorageBackend {
|
|
|
132
132
|
let baseDir;
|
|
133
133
|
switch (type) {
|
|
134
134
|
case 'Dataset':
|
|
135
|
-
backends = this
|
|
135
|
+
backends = this.#datasetBackendCache;
|
|
136
136
|
baseDir = this.datasetsDirectory;
|
|
137
137
|
break;
|
|
138
138
|
case 'KeyValueStore':
|
|
139
|
-
backends = this
|
|
139
|
+
backends = this.#keyValueStoreBackendCache;
|
|
140
140
|
baseDir = this.keyValueStoresDirectory;
|
|
141
141
|
break;
|
|
142
142
|
case 'RequestQueue':
|
|
143
|
-
backends = this
|
|
143
|
+
backends = this.#requestQueueBackendCache;
|
|
144
144
|
baseDir = this.requestQueuesDirectory;
|
|
145
145
|
break;
|
|
146
146
|
default:
|
|
@@ -281,6 +281,6 @@ export class FileSystemStorageBackend {
|
|
|
281
281
|
* are not stuck (until their lock expires) for the next consumer of the same on-disk queue.
|
|
282
282
|
*/
|
|
283
283
|
async teardown() {
|
|
284
|
-
await Promise.all(this
|
|
284
|
+
await Promise.all(this.#requestQueueBackendCache.map(async (queue) => queue.persistState()));
|
|
285
285
|
}
|
|
286
286
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/fs-storage",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.135",
|
|
4
4
|
"description": "A file-system storage implementation of the Apify API",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@crawlee/fs-storage-native": "0.1.5-beta.18",
|
|
46
|
-
"@crawlee/types": "4.0.0-beta.
|
|
47
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
46
|
+
"@crawlee/types": "4.0.0-beta.135",
|
|
47
|
+
"@crawlee/utils": "4.0.0-beta.135",
|
|
48
48
|
"zod": "^4.4.3"
|
|
49
49
|
},
|
|
50
50
|
"lerna": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ca0325880bbcc753d97506796e9bda3b35bca201"
|
|
58
58
|
}
|