Skip to content

Commit

Permalink
Address PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonWeber committed Feb 1, 2024
1 parent 00c10d1 commit 935ca14
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Library/FileSystemHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ export const getShallowDirectorySize = async (directory: string): Promise<number
totalSize += fileStats.size;
}
}
return totalSize;
} catch {
Logging.warn(`Failed to get directory size for ${directory}`);
return totalSize;
}
return totalSize;
};

/**
Expand All @@ -68,15 +67,14 @@ export const getShallowDirectorySizeSync = (directory: string): number => {
for (let i = 0; i < files.length; i++) {
totalSize += fs.statSync(path.join(directory, files[i])).size;
}
return totalSize;
} catch {
Logging.warn(`Failed to get directory size synchronously for ${directory}`)
return totalSize;
}
return totalSize
}

/**
* Computes the size (in bytes) of a file asynchronously.
* Computes the size (in bytes) of a file asynchronously. Returns -1 if the file does not exist.
*/
export const getShallowFileSize = async (filePath: string): Promise<number> => {
try {
Expand All @@ -86,6 +84,7 @@ export const getShallowFileSize = async (filePath: string): Promise<number> => {
}
} catch {
Logging.warn(`Failed to get file size for ${filePath}`);
return -1;
}
}

0 comments on commit 935ca14

Please sign in to comment.