@@ -9,13 +9,13 @@ import { Key } from 'interface-datastore'
9
9
import { ShardingDatastore , shard } from 'datastore-core'
10
10
import { isNode , isElectronMain } from 'ipfs-utils/src/env.js'
11
11
import { interfaceDatastoreTests } from 'interface-datastore-tests'
12
- import { DatastoreFs } from '../src/index.js'
12
+ import { FsDatastore } from '../src/index.js'
13
13
import tempdir from 'ipfs-utils/src/temp-dir.js'
14
14
15
15
const rimraf = promisify ( rmrf )
16
16
const utf8Encoder = new TextEncoder ( )
17
17
18
- describe ( 'DatastoreFs ' , ( ) => {
18
+ describe ( 'FsDatastore ' , ( ) => {
19
19
if ( ! ( isNode || isElectronMain ) ) {
20
20
it ( 'only supports node.js and electron main' , ( ) => {
21
21
@@ -28,23 +28,23 @@ describe('DatastoreFs', () => {
28
28
it ( 'defaults - folder missing' , ( ) => {
29
29
const dir = tempdir ( )
30
30
expect (
31
- ( ) => new DatastoreFs ( dir )
31
+ ( ) => new FsDatastore ( dir )
32
32
) . to . not . throw ( )
33
33
} )
34
34
35
35
it ( 'defaults - folder exists' , ( ) => {
36
36
const dir = tempdir ( )
37
37
mkdirp . sync ( dir )
38
38
expect (
39
- ( ) => new DatastoreFs ( dir )
39
+ ( ) => new FsDatastore ( dir )
40
40
) . to . not . throw ( )
41
41
} )
42
42
} )
43
43
44
44
describe ( 'open' , ( ) => {
45
45
it ( 'createIfMissing: false - folder missing' , ( ) => {
46
46
const dir = tempdir ( )
47
- const store = new DatastoreFs ( dir , { createIfMissing : false } )
47
+ const store = new FsDatastore ( dir , { createIfMissing : false } )
48
48
expect (
49
49
( ) => store . open ( )
50
50
) . to . throw ( )
@@ -53,7 +53,7 @@ describe('DatastoreFs', () => {
53
53
it ( 'errorIfExists: true - folder exists' , ( ) => {
54
54
const dir = tempdir ( )
55
55
mkdirp . sync ( dir )
56
- const store = new DatastoreFs ( dir , { errorIfExists : true } )
56
+ const store = new FsDatastore ( dir , { errorIfExists : true } )
57
57
expect (
58
58
( ) => store . open ( )
59
59
) . to . throw ( )
@@ -62,7 +62,7 @@ describe('DatastoreFs', () => {
62
62
63
63
it ( '_encode and _decode' , ( ) => {
64
64
const dir = tempdir ( )
65
- const fs = new DatastoreFs ( dir )
65
+ const fs = new FsDatastore ( dir )
66
66
67
67
expect (
68
68
// @ts -ignore
@@ -82,7 +82,7 @@ describe('DatastoreFs', () => {
82
82
83
83
it ( 'deleting files' , async ( ) => {
84
84
const dir = tempdir ( )
85
- const fs = new DatastoreFs ( dir )
85
+ const fs = new FsDatastore ( dir )
86
86
const key = new Key ( '1234' )
87
87
88
88
await fs . put ( key , Uint8Array . from ( [ 0 , 1 , 2 , 3 ] ) )
@@ -98,7 +98,7 @@ describe('DatastoreFs', () => {
98
98
99
99
it ( 'deleting non-existent files' , async ( ) => {
100
100
const dir = tempdir ( )
101
- const fs = new DatastoreFs ( dir )
101
+ const fs = new FsDatastore ( dir )
102
102
const key = new Key ( '5678' )
103
103
104
104
await fs . delete ( key )
@@ -113,7 +113,7 @@ describe('DatastoreFs', () => {
113
113
114
114
it ( 'sharding files' , async ( ) => {
115
115
const dir = tempdir ( )
116
- const fstore = new DatastoreFs ( dir )
116
+ const fstore = new FsDatastore ( dir )
117
117
await ShardingDatastore . create ( fstore , new shard . NextToLast ( 2 ) )
118
118
119
119
const file = await fs . promises . readFile ( path . join ( dir , shard . SHARDING_FN ) )
@@ -125,7 +125,7 @@ describe('DatastoreFs', () => {
125
125
} )
126
126
127
127
it ( 'query' , async ( ) => {
128
- const fs = new DatastoreFs ( path . join ( process . cwd ( ) , '/test/test-repo/blocks' ) )
128
+ const fs = new FsDatastore ( path . join ( process . cwd ( ) , '/test/test-repo/blocks' ) )
129
129
const res = [ ]
130
130
for await ( const q of fs . query ( { } ) ) {
131
131
res . push ( q )
@@ -135,7 +135,7 @@ describe('DatastoreFs', () => {
135
135
136
136
it ( 'interop with go' , async ( ) => {
137
137
const repodir = path . join ( process . cwd ( ) , '/test/test-repo/blocks' )
138
- const fstore = new DatastoreFs ( repodir )
138
+ const fstore = new FsDatastore ( repodir )
139
139
const key = new Key ( 'CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY' )
140
140
const expected = fs . readFileSync ( path . join ( repodir , 'VO' , key . toString ( ) + '.data' ) )
141
141
const flatfs = await ShardingDatastore . open ( fstore )
@@ -152,7 +152,7 @@ describe('DatastoreFs', () => {
152
152
153
153
interfaceDatastoreTests ( {
154
154
setup : ( ) => {
155
- return new DatastoreFs ( dir )
155
+ return new FsDatastore ( dir )
156
156
} ,
157
157
teardown : ( ) => {
158
158
return rimraf ( dir )
@@ -165,7 +165,7 @@ describe('DatastoreFs', () => {
165
165
166
166
interfaceDatastoreTests ( {
167
167
setup : ( ) => {
168
- return new ShardingDatastore ( new DatastoreFs ( dir ) , new shard . NextToLast ( 2 ) )
168
+ return new ShardingDatastore ( new FsDatastore ( dir ) , new shard . NextToLast ( 2 ) )
169
169
} ,
170
170
teardown : ( ) => {
171
171
return rimraf ( dir )
@@ -175,7 +175,7 @@ describe('DatastoreFs', () => {
175
175
176
176
it ( 'can survive concurrent writes' , async ( ) => {
177
177
const dir = tempdir ( )
178
- const fstore = new DatastoreFs ( dir )
178
+ const fstore = new FsDatastore ( dir )
179
179
const key = new Key ( 'CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY' )
180
180
const value = utf8Encoder . encode ( 'Hello world' )
181
181
@@ -190,7 +190,7 @@ describe('DatastoreFs', () => {
190
190
191
191
it ( 'can survive putRaw and getRaw with an empty extension' , async ( ) => {
192
192
const dir = tempdir ( )
193
- const fstore = new DatastoreFs ( dir , {
193
+ const fstore = new FsDatastore ( dir , {
194
194
extension : ''
195
195
} )
196
196
const key = new Key ( 'CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY' )
0 commit comments