@@ -319,10 +319,9 @@ function get_config_files_tmpdir() {
319
319
* @param {string } config_data
320
320
*/
321
321
async function create_config_file ( fs_context , schema_dir , config_path , config_data ) {
322
- const is_gpfs = _is_gpfs ( fs_context ) ;
323
- const open_mode = is_gpfs ? 'wt' : 'w' ;
322
+ const open_mode = 'w' ;
323
+ let open_path ;
324
324
let upload_tmp_file ;
325
- let gpfs_dst_file ;
326
325
try {
327
326
// validate config file doesn't exist
328
327
try {
@@ -336,37 +335,30 @@ async function create_config_file(fs_context, schema_dir, config_path, config_da
336
335
dbg . log1 ( 'create_config_file:: config_path:' , config_path , 'config_data:' , config_data , 'is_gpfs:' , open_mode ) ;
337
336
// create config dir if it does not exist
338
337
await _create_path ( schema_dir , fs_context , config . BASE_MODE_CONFIG_DIR ) ;
339
- // when using GPFS open dst file as soon as possible for later linkat validation
340
- if ( is_gpfs ) gpfs_dst_file = await open_file ( fs_context , schema_dir , config_path , 'w*' , config . BASE_MODE_CONFIG_FILE ) ;
341
338
342
339
// open tmp file (in GPFS we open the parent dir using wt open mode)
343
340
const tmp_dir_path = path . join ( schema_dir , get_config_files_tmpdir ( ) ) ;
344
- let open_path = is_gpfs ? config_path : await _generate_unique_path ( fs_context , tmp_dir_path ) ;
341
+ open_path = await _generate_unique_path ( fs_context , tmp_dir_path ) ;
345
342
upload_tmp_file = await open_file ( fs_context , schema_dir , open_path , open_mode , config . BASE_MODE_CONFIG_FILE ) ;
346
343
347
344
// write tmp file data
348
345
await upload_tmp_file . writev ( fs_context , [ Buffer . from ( config_data ) ] , 0 ) ;
349
346
350
- // moving tmp file to config path atomically
351
- let src_stat ;
352
- let gpfs_options ;
353
- if ( is_gpfs ) {
354
- gpfs_options = { dst_file : gpfs_dst_file , dir_file : upload_tmp_file } ;
355
- // open path in GPFS is the parent dir
356
- open_path = schema_dir ;
357
- } else {
358
- src_stat = await nb_native ( ) . fs . stat ( fs_context , open_path ) ;
359
- }
360
- dbg . log1 ( 'create_config_file:: moving from:' , open_path , 'to:' , config_path , 'is_gpfs=' , is_gpfs ) ;
347
+ dbg . log1 ( 'create_config_file:: moving from:' , open_path , 'to:' , config_path ) ;
361
348
362
- await safe_move ( fs_context , open_path , config_path , src_stat , gpfs_options , tmp_dir_path ) ;
349
+ await nb_native ( ) . fs . link ( fs_context , open_path , config_path ) ;
363
350
364
351
dbg . log1 ( 'create_config_file:: done' , config_path ) ;
365
352
} catch ( err ) {
366
353
dbg . error ( 'create_config_file:: error' , err ) ;
367
354
throw err ;
368
355
} finally {
369
- await finally_close_files ( fs_context , [ upload_tmp_file , gpfs_dst_file ] ) ;
356
+ await finally_close_files ( fs_context , [ upload_tmp_file ] ) ;
357
+ try {
358
+ await nb_native ( ) . fs . unlink ( fs_context , open_path ) ;
359
+ } catch ( error ) {
360
+ dbg . log0 ( `create_config_file:: unlink tmp file failed with error ${ error } , skipping` ) ;
361
+ }
370
362
}
371
363
}
372
364
0 commit comments