@@ -52,8 +52,6 @@ export default function App() {
5252 const executeGetLz4VersionNumber = async ( ) => {
5353 const _versionNumber = await getLz4VersionNumber ( ) ;
5454
55- console . log ( { _versionNumber } ) ;
56-
5755 setVersionNumber ( _versionNumber ) ;
5856 } ;
5957
@@ -95,7 +93,12 @@ export default function App() {
9593 operation : 'compress' ,
9694 } ) ;
9795 } catch ( error ) {
98- console . log ( { error } ) ;
96+ setFileOperationResult ( {
97+ ...( error as FileOperationResult ) ,
98+ sourcePath,
99+ destinationPath,
100+ operation : 'compress' ,
101+ } ) ;
99102 }
100103 }
101104 } catch ( error ) {
@@ -106,26 +109,35 @@ export default function App() {
106109 const executeCompressFileUsingDocumentPicker = async ( ) => {
107110 onReset ( ) ;
108111
109- const [ file ] = await pick ( { copyTo : 'cachesDirectory' } ) ;
110-
111- if ( ! file || ! file . fileCopyUri ) return ;
112-
113- const sourcePath = file . fileCopyUri ;
114- const destinationPath = file . fileCopyUri . replace ( / ( .* ) ( \. .* ) / , '$1.lz4' ) ;
115-
116112 try {
117- const decompressFileResult = await compressFile (
118- sourcePath ,
119- destinationPath ,
120- onProgress
121- ) ;
122-
123- setFileOperationResult ( {
124- ...decompressFileResult ,
125- sourcePath,
126- destinationPath,
127- operation : 'compress' ,
128- } ) ;
113+ const [ file ] = await pick ( { copyTo : 'cachesDirectory' } ) ;
114+
115+ if ( ! file || ! file . fileCopyUri ) return ;
116+
117+ const sourcePath = file . fileCopyUri ;
118+ const destinationPath = file . fileCopyUri . replace ( / ( .* ) ( \. .* ) / , '$1.lz4' ) ;
119+
120+ try {
121+ const compressFileResult = await compressFile (
122+ sourcePath ,
123+ destinationPath ,
124+ onProgress
125+ ) ;
126+
127+ setFileOperationResult ( {
128+ ...compressFileResult ,
129+ sourcePath,
130+ destinationPath,
131+ operation : 'compress' ,
132+ } ) ;
133+ } catch ( error ) {
134+ setFileOperationResult ( {
135+ ...( error as FileOperationResult ) ,
136+ sourcePath,
137+ destinationPath,
138+ operation : 'compress' ,
139+ } ) ;
140+ }
129141 } catch ( error ) {
130142 console . log ( { error } ) ;
131143 }
@@ -134,26 +146,35 @@ export default function App() {
134146 const executeDecompressFile = async ( ) => {
135147 onReset ( ) ;
136148
137- const [ file ] = await pick ( { copyTo : 'cachesDirectory' } ) ;
138-
139- if ( ! file || ! file . fileCopyUri ) return ;
140-
141- const sourcePath = file . fileCopyUri ;
142- const destinationPath = file . fileCopyUri . replace ( / ( .* ) ( \. .* ) / , '$1.lz4' ) ;
143-
144149 try {
145- const decompressFileResult = await decompressFile (
146- sourcePath ,
147- destinationPath ,
148- onProgress
149- ) ;
150-
151- setFileOperationResult ( {
152- ...decompressFileResult ,
153- sourcePath,
154- destinationPath,
155- operation : 'decompress' ,
156- } ) ;
150+ const [ file ] = await pick ( { copyTo : 'cachesDirectory' } ) ;
151+
152+ if ( ! file || ! file . fileCopyUri ) return ;
153+
154+ const sourcePath = file . fileCopyUri ;
155+ const destinationPath = file . fileCopyUri . replace ( / ( .* ) ( \. .* ) / , '$1.lz4' ) ;
156+
157+ try {
158+ const decompressFileResult = await decompressFile (
159+ sourcePath ,
160+ destinationPath ,
161+ onProgress
162+ ) ;
163+
164+ setFileOperationResult ( {
165+ ...decompressFileResult ,
166+ sourcePath,
167+ destinationPath,
168+ operation : 'decompress' ,
169+ } ) ;
170+ } catch ( error ) {
171+ setFileOperationResult ( {
172+ ...( error as FileOperationResult ) ,
173+ sourcePath,
174+ destinationPath,
175+ operation : 'decompress' ,
176+ } ) ;
177+ }
157178 } catch ( error ) {
158179 console . log ( { error } ) ;
159180 }
0 commit comments