Skip to content

Commit

Permalink
feat: replace synchronous file read with stream-based reading for imp…
Browse files Browse the repository at this point in the history
…roved performance
  • Loading branch information
sanjaikumar-bruno committed Jan 6, 2025
1 parent 413b4a8 commit 6650850
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/bruno-electron/src/ipc/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { makeAxiosInstance } = require('./axios-instance');
const { addAwsV4Interceptor, resolveAwsV4Credentials } = require('./awsv4auth-helper');
const { addDigestInterceptor } = require('./digestauth-helper');
const { shouldUseProxy, PatchedHttpsProxyAgent } = require('../../utils/proxy-util');
const { chooseFileToSave, writeBinaryFile, writeFile, readFile, getFileSize } = require('../../utils/filesystem');
const { chooseFileToSave, writeBinaryFile, writeFile, readFileStream, getFileSize } = require('../../utils/filesystem');
const { getCookieStringForUrl, addCookieToJar, getDomainsWithCookies } = require('../../utils/cookies');
const {
resolveOAuth2AuthorizationCodeAccessToken,
Expand Down Expand Up @@ -460,7 +460,7 @@ const registerNetworkIpc = (mainWindow) => {
const rawFilePath = request.data;

try {
request.data = await readFile(rawFilePath);
request.data = await readFileStream(rawFilePath);
const newContentType = mime.lookup(rawFilePath) || GENERIC_FILE_CONTENT_TYPE;
const fileSize = await getFileSize(rawFilePath);

Expand Down
4 changes: 2 additions & 2 deletions packages/bruno-electron/src/utils/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const safeToRename = (oldPath, newPath) => {
}
};

const readFile = (path) => {
const readFileStream = (path) => {
return new Promise((resolve, reject) => {
const stream = fs.createReadStream(path);
let data = '';
Expand Down Expand Up @@ -280,6 +280,6 @@ module.exports = {
safeToRename,
isValidFilename,
hasSubDirectories,
readFile,
readFileStream,
getFileSize
};

0 comments on commit 6650850

Please sign in to comment.