2
2
3
3
from typing_extensions import override
4
4
5
+ from crawlee ._utils .docs import docs_group
5
6
from crawlee .configuration import Configuration
6
7
from crawlee .storage_clients ._base import StorageClient
7
8
10
11
from ._request_queue_client import FileSystemRequestQueueClient
11
12
12
13
14
+ @docs_group ('Classes' )
13
15
class FileSystemStorageClient (StorageClient ):
14
- """File system storage client."""
16
+ """File system implementation of the storage client.
17
+
18
+ This storage client provides access to datasets, key-value stores, and request queues that persist data
19
+ to the local file system. Each storage type is implemented with its own specific file system client
20
+ that stores data in a structured directory hierarchy.
21
+
22
+ Data is stored in JSON format in predictable file paths, making it easy to inspect and manipulate
23
+ the stored data outside of the Crawlee application if needed.
24
+
25
+ All data persists between program runs but is limited to access from the local machine
26
+ where the files are stored.
27
+ """
15
28
16
29
@override
17
30
async def open_dataset_client (
@@ -23,10 +36,7 @@ async def open_dataset_client(
23
36
) -> FileSystemDatasetClient :
24
37
configuration = configuration or Configuration .get_global_configuration ()
25
38
client = await FileSystemDatasetClient .open (id = id , name = name , configuration = configuration )
26
-
27
- if configuration .purge_on_start and client .metadata .name is None :
28
- await client .purge ()
29
-
39
+ await self ._purge_if_needed (client , configuration )
30
40
return client
31
41
32
42
@override
@@ -39,10 +49,7 @@ async def open_key_value_store_client(
39
49
) -> FileSystemKeyValueStoreClient :
40
50
configuration = configuration or Configuration .get_global_configuration ()
41
51
client = await FileSystemKeyValueStoreClient .open (id = id , name = name , configuration = configuration )
42
-
43
- if configuration .purge_on_start and client .metadata .name is None :
44
- await client .purge ()
45
-
52
+ await self ._purge_if_needed (client , configuration )
46
53
return client
47
54
48
55
@override
@@ -55,8 +62,5 @@ async def open_request_queue_client(
55
62
) -> FileSystemRequestQueueClient :
56
63
configuration = configuration or Configuration .get_global_configuration ()
57
64
client = await FileSystemRequestQueueClient .open (id = id , name = name , configuration = configuration )
58
-
59
- if configuration .purge_on_start and client .metadata .name is None :
60
- await client .purge ()
61
-
65
+ await self ._purge_if_needed (client , configuration )
62
66
return client
0 commit comments