Skip to content

Commit bed0f4b

Browse files
committed
Use non-blocking IO in StorageObject
1 parent 5c21e94 commit bed0f4b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/sdk/storage-object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ObjectDownloadURLView,
77
ObjectListParams,
88
} from '../resources/objects';
9-
import * as fs from 'node:fs';
9+
import * as fs from 'node:fs/promises';
1010
import * as path from 'node:path';
1111

1212
// Extract the content type from the API types
@@ -293,7 +293,7 @@ export class StorageObject {
293293

294294
// Check if file exists and get stats
295295
try {
296-
const stats = fs.statSync(filePath);
296+
const stats = await fs.stat(filePath);
297297
if (!stats.isFile()) {
298298
throw new Error(`Path is not a file: ${filePath}`);
299299
}
@@ -306,7 +306,7 @@ export class StorageObject {
306306
// Read file content immediately to fail fast if file doesn't exist
307307
let fileBuffer: Buffer;
308308
try {
309-
fileBuffer = fs.readFileSync(filePath);
309+
fileBuffer = await fs.readFile(filePath);
310310
} catch (error) {
311311
throw new Error(
312312
`Failed to read file ${filePath}: ${error instanceof Error ? error.message : 'Unknown error'}`,

0 commit comments

Comments
 (0)