File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ const types = [
11
11
'directory' ,
12
12
'file' ,
13
13
'metadata' ,
14
- 'symlink'
14
+ 'symlink' ,
15
+ 'hamt-sharded-directory'
15
16
]
16
17
17
18
function Data ( type , data ) {
@@ -56,6 +57,7 @@ function Data (type, data) {
56
57
case 'file' : type = unixfsData . DataType . File ; break
57
58
case 'metadata' : type = unixfsData . DataType . Metadata ; break
58
59
case 'symlink' : type = unixfsData . DataType . Symlink ; break
60
+ case 'hamt-sharded-directory' : type = unixfsData . DataType . HAMTShard ; break
59
61
default :
60
62
throw new Error ( `Unkown type: "${ this . type } "` )
61
63
}
@@ -69,7 +71,9 @@ function Data (type, data) {
69
71
Type : type ,
70
72
Data : this . data ,
71
73
filesize : fileSize ,
72
- blocksizes : this . blockSizes . length > 0 ? this . blockSizes : undefined
74
+ blocksizes : this . blockSizes . length > 0 ? this . blockSizes : undefined ,
75
+ hashType : this . hashType ,
76
+ fanout : this . fanout
73
77
} )
74
78
}
75
79
}
Original file line number Diff line number Diff line change @@ -7,12 +7,16 @@ module.exports = `message Data {
7
7
File = 2;
8
8
Metadata = 3;
9
9
Symlink = 4;
10
+ HAMTShard = 5;
10
11
}
11
12
12
13
required DataType Type = 1;
13
14
optional bytes Data = 2;
14
15
optional uint64 filesize = 3;
15
16
repeated uint64 blocksizes = 4;
17
+
18
+ optional uint64 hashType = 5;
19
+ optional uint64 fanout = 6;
16
20
}
17
21
18
22
message Metadata {
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ describe('unixfs-format', () => {
34
34
done ( )
35
35
} )
36
36
37
+ it ( 'hamt-sharded-directory' , ( done ) => {
38
+ const data = new UnixFS ( 'hamt-sharded-directory' )
39
+ const marsheled = data . marshal ( )
40
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
41
+ expect ( data . type ) . to . equal ( unmarsheled . type )
42
+ expect ( data . data ) . to . deep . equal ( unmarsheled . data )
43
+ expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
44
+ expect ( data . fileSize ( ) ) . to . deep . equal ( unmarsheled . fileSize ( ) )
45
+ done ( )
46
+ } )
47
+
37
48
it ( 'file' , ( done ) => {
38
49
const data = new UnixFS ( 'file' , new Buffer ( 'batata' ) )
39
50
const marsheled = data . marshal ( )
You can’t perform that action at this time.
0 commit comments