async function saveFileToIPFSFromFS ({ logContext }, cnodeUserUUID, srcPath, ipfs) {
  const logger = genericLogger.child(logContext)

  // make sure user has authenticated before saving file
  if (!cnodeUserUUID) {
    throw new Error('User must be authenticated to save a file')
  }

  // Add to IPFS without pinning and retrieve multihash
  let multihash = (await ipfs.addFromFs(srcPath, { pin: false }))[0].hash

  // store file copy by multihash for future retrieval
  const dstPath = DiskManager.computeFilePath(multihash)

  try {
    await fs.copyFile(srcPath, dstPath)
  } catch (e) {
    // if we see a ENOSPC error, log out the disk space and inode details from the system
    if (e.message.includes('ENOSPC')) {
      await Promise.all([
        Utils.runShellCommand(`df`, ['-h'], logger),
        Utils.runShellCommand(`df`, ['-ih'], logger)
      ])
    }
    throw e
  }

  return { multihash, dstPath }
}
/**
 * Given file path on disk, adds file to IPFS + re-saves under /multihash name
 *
 * @dev - only call this function when file is already stored to disk, else use saveFileFromBufferToIPFSAndDisk()
 */
Given file path on disk, adds file to IPFS + re-saves under /multihash name
@dev - only call this function when file is already stored to disk, else use saveFileFromBufferToIPFSAndDisk()
Given file path on disk adds file to IPFS + re - saves under / multihash name @dev - only call this function when file is already stored to disk else use saveFileFromBufferToIPFSAndDisk ()
async function saveFileToIPFSFromFS ({ logContext }, cnodeUserUUID, srcPath, ipfs) {
  const logger = genericLogger.child(logContext)
  if (!cnodeUserUUID) {
    throw new Error('User must be authenticated to save a file')
  }
  let multihash = (await ipfs.addFromFs(srcPath, { pin: false }))[0].hash
  const dstPath = DiskManager.computeFilePath(multihash)
  try {
    await fs.copyFile(srcPath, dstPath)
  } catch (e) {
    if (e.message.includes('ENOSPC')) {
      await Promise.all([
        Utils.runShellCommand(`df`, ['-h'], logger),
        Utils.runShellCommand(`df`, ['-ih'], logger)
      ])
    }
    throw e
  }
  return { multihash, dstPath }
}
async function saveFileToIPFSFromFS ( { logContext } , cnodeUserUUID , srcPath , ipfs ) { const logger = genericLogger . child ( logContext ) if ( ! cnodeUserUUID ) { throw new Error ( 'User must be authenticated to save a file' ) } let multihash = ( await ipfs . addFromFs ( srcPath , { pin : false } ) ) [ 0 ] . hash const dstPath = DiskManager . computeFilePath ( multihash ) try { await fs . copyFile ( srcPath , dstPath ) } catch ( e ) { if ( e . message . includes ( 'ENOSPC' ) ) { await Promise . all ( [ Utils . runShellCommand ( ` ` , [ '-h' ] , logger ) , Utils . runShellCommand ( ` ` , [ '-ih' ] , logger ) ] ) } throw e } return { multihash , dstPath } }
Given file path on disk, adds file to IPFS + re-saves under /multihash name
 @dev - only call this function when file is already stored to disk, else use saveFileFromBufferToIPFSAndDisk()
Given file path on disk adds file to IPFS + re - saves under / multihash name @dev - only call this function when file is already stored to disk else use saveFileFromBufferToIPFSAndDisk ()
// make sure user has authenticated before saving file // Add to IPFS without pinning and retrieve multihash // store file copy by multihash for future retrieval // if we see a ENOSPC error, log out the disk space and inode details from the system