persist.js
/*      problem/
 * Flush the given shard file to
 * ensure that it is correctly
 * persisted.
 *
 *      way/
 * Flush the directory and file
 * (windows doesn't support
 * directory flushing)
 */
problem
Flush the given shard file to
ensure that it is correctly
persisted.

way
Flush the directory and file
(windows doesn't support
directory flushing)
problem Flush the given shard file to ensure that it is correctly persisted . way Flush the directory and file ( windows doesn ' t support directory flushing )
function flush(folder, shard) {
    flush_dir_1(folder, (err) => {
        if(err) kd.ERR(err)
        let p = path.join(folder, shardFileName(shard))
        flush_file_1(p)
    })
    function flush_dir_1(folder, cb) {
        if(process.platform === 'win32' || process.platform === 'win64') return cb()
        fs.open(folder, 'r', (err, fd) => {
            if(err) cb(err)
            else fs.fsync(fd, (err) => {
                if(err) kd.ERR(err)
                fs.close(fd, cb)
            })
        })
    }
    function flush_file_1(p) {
        fs.open(p, 'r+', (err, fd) => {
            if(err) kd.ERR(err)
            else fs.fsync(fd, (err) => {
                if(err) kd.ERR(err)
                fs.close(fd, (err) => {
                    if(err) kd.ERR(err)
                })
            })
        })
    }
}
function flush ( folder , shard ) { flush_dir_1 ( folder , ( err ) => { if ( err ) kd . ERR ( err ) let p = path . join ( folder , shardFileName ( shard ) ) flush_file_1 ( p ) } ) function flush_dir_1 ( folder , cb ) { if ( process . platform === 'win32' || process . platform === 'win64' ) return cb ( ) fs . open ( folder , 'r' , ( err , fd ) => { if ( err ) cb ( err ) else fs . fsync ( fd , ( err ) => { if ( err ) kd . ERR ( err ) fs . close ( fd , cb ) } ) } ) } function flush_file_1 ( p ) { fs . open ( p , 'r+' , ( err , fd ) => { if ( err ) kd . ERR ( err ) else fs . fsync ( fd , ( err ) => { if ( err ) kd . ERR ( err ) fs . close ( fd , ( err ) => { if ( err ) kd . ERR ( err ) } ) } ) } ) } }
problem
 Flush the given shard file to
 ensure that it is correctly
 persisted.
problem Flush the given shard file to ensure that it is correctly persisted .