@@ -16,22 +16,36 @@ function phoenixFsCheck() {
1616 }
1717}
1818
19- function checkReadWriteInMountPath ( ) {
20- fs . writeFile ( `${ mountTestPath } /a.txt` , 'hello World' , 'utf8' , ( err ) => {
19+ function checkWriteInMountPath ( ) {
20+ console . log ( 'worker: checkWriteInMountPath' ) ;
21+ fs . writeFile ( `${ mountTestPath } /workerWrite.txt` , 'hello World' , 'utf8' , ( err ) => {
2122 if ( ! err ) {
22- postMessage ( 'RWMountCheck .ok' ) ;
23+ postMessage ( 'writeMountCheck .ok' ) ;
2324 return ;
2425 }
2526 console . log ( err ) ;
2627 } ) ;
2728}
2829
30+ function checkReadInMountPath ( ) {
31+ console . log ( 'worker: checkReadInMountPath' ) ;
32+ fs . readFile ( `${ mountTestPath } /workerWrite.txt` , ( err , content ) => {
33+ if ( ! err && content === 'hello World' ) {
34+ postMessage ( 'readMountCheck.ok' ) ;
35+ return ;
36+ }
37+ console . log ( 'file read:' , err , content ) ;
38+ } ) ;
39+ }
40+
2941self . addEventListener ( 'message' , ( event ) => {
30- console . log ( 'Worker: ' , event ) ;
42+ console . log ( 'Worker received: ' , event ) ;
3143 let command = event . data ;
3244 switch ( command ) {
3345 case 'fsCheck' : fsCheck ( ) ; break ;
3446 case 'phoenixFsCheck' : phoenixFsCheck ( ) ; break ;
35- case 'RWMountCheck' : checkReadWriteInMountPath ( ) ; break ;
47+ case 'writeMountCheck' : checkWriteInMountPath ( ) ; break ;
48+ case 'readMountCheck' : checkReadInMountPath ( ) ; break ;
49+ default : console . error ( 'unknown worker command: ' , command ) ;
3650 }
3751} , false ) ;
0 commit comments