diff --git a/CHANGELOG.md b/CHANGELOG.md index ed611a9..dfdd0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.1-alpha.14](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.10...v0.0.1-alpha.14) (2024-09-10) + + +### Features + +* add plimit to directory add ([468cff2](https://github.com/DIG-Network/dig-chia-sdk/commit/468cff28397c993b22af7388a8472b1d2068aebd)) + ### [0.0.1-alpha.13](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.10...v0.0.1-alpha.13) (2024-09-10) diff --git a/package-lock.json b/package-lock.json index 71efcfb..3f19a8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.13", + "version": "0.0.1-alpha.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.13", + "version": "0.0.1-alpha.14", "license": "ISC", "dependencies": { "bip39": "^3.1.0", diff --git a/package.json b/package.json index 9ea6efb..aa01262 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.13", + "version": "0.0.1-alpha.14", "description": "", "type": "commonjs", "main": "./dist/index.js", diff --git a/src/utils/directoryUtils.ts b/src/utils/directoryUtils.ts index 4008332..eea4852 100644 --- a/src/utils/directoryUtils.ts +++ b/src/utils/directoryUtils.ts @@ -76,3 +76,27 @@ export const addDirectory = async ( // Run tasks with limited concurrency (set the concurrency limit as needed) await limitConcurrency(10, tasks); // Adjust 10 based on your system limits }; + +/** + * Calculate the total size of the DIG_FOLDER_PATH + * @param folderPath - The path of the folder to calculate size. + * @returns The total size of the folder in bytes. + */ +export const calculateFolderSize = (folderPath: string): bigint => { + let totalSize = BigInt(0); + + const files = fs.readdirSync(folderPath); + + for (const file of files) { + const filePath = path.join(folderPath, file); + const stat = fs.statSync(filePath); + + if (stat.isDirectory()) { + totalSize += calculateFolderSize(filePath); + } else { + totalSize += BigInt(stat.size); + } + } + + return totalSize; +}; \ No newline at end of file