File tree Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -393,7 +393,9 @@ export async function filterUselessFileInits(
393
393
394
394
for ( let i = 0 ; i < batch . length ; i ++ ) {
395
395
if ( ! results [ i ] ) {
396
- throw new Error ( `Could not retrieve totalChunk data entry for file ${ batch [ i ] . preStore . location } ` ) ;
396
+ throw new Error (
397
+ `Could not retrieve totalChunk data entry for file ${ batch [ i ] . preStore . location } `
398
+ )
397
399
}
398
400
if (
399
401
( results [ i ] as Uint8Array ) . length !== U32 . SIZE_BYTE ||
Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ export async function getGlobalMetadata(
37
37
const metadataKeyBytes = metadataKeys [ index ] . slice (
38
38
GLOBAL_METADATA_TAG . length
39
39
)
40
- const key = String . fromCharCode ( ...new Uint8Array ( metadataKeyBytes ) ) ;
40
+ const key = String . fromCharCode ( ...new Uint8Array ( metadataKeyBytes ) )
41
41
if ( ! m ) {
42
- throw new Error ( `Global metadata with key ${ key } has empty value` ) ;
42
+ throw new Error ( `Global metadata with key ${ key } has empty value` )
43
43
}
44
44
const value = String . fromCharCode ( ...new Uint8Array ( m ) )
45
45
Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ export async function listFiles(
23
23
const fileLocations = await provider . readStorage ( scAddress , allStorageKeys )
24
24
25
25
return fileLocations . map ( ( location , i ) => {
26
- if ( ! location ) {
27
- throw new Error ( `File location not found at index ${ i } ` ) ;
28
- }
29
- return String . fromCharCode ( ...new Uint8Array ( location ) ) ;
26
+ if ( ! location ) {
27
+ throw new Error ( `File location not found at index ${ i } ` )
30
28
}
31
- ) ;
29
+ return String . fromCharCode ( ...new Uint8Array ( location ) )
30
+ } )
32
31
}
33
32
34
33
/**
@@ -87,15 +86,15 @@ export async function getFileFromAddress(
87
86
datastoreKeys . push ( fileChunkKey ( new Uint8Array ( filePathHash ) , i ) )
88
87
}
89
88
90
- const rawChunks = ( await provider . readStorage ( scAddress , datastoreKeys ) )
91
- . map ( // allow to return Uint8Array[] instead of (Uint8Array | null)[]
92
- ( chunk , i ) => {
93
- if ( ! chunk ) {
94
- throw new Error ( `file ${ filePath } Chunk ${ i } not found` ) ;
95
- }
96
- return chunk ;
89
+ const rawChunks = ( await provider . readStorage ( scAddress , datastoreKeys ) ) . map (
90
+ // allow to return Uint8Array[] instead of (Uint8Array | null)[]
91
+ ( chunk , i ) => {
92
+ if ( ! chunk ) {
93
+ throw new Error ( `file ${ filePath } Chunk ${ i } not found` )
97
94
}
98
- ) ;
95
+ return chunk
96
+ }
97
+ )
99
98
100
99
const totalLength = rawChunks . reduce ( ( acc , chunk ) => acc + chunk . length , 0 )
101
100
const concatenatedArray = new Uint8Array ( totalLength )
You can’t perform that action at this time.
0 commit comments