@lvce-editor/file-system-process 5.16.1 → 5.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1725,13 +1725,14 @@ const getFolderSizeInternal = async path => {
1725
1725
  }
1726
1726
  let total = 0;
1727
1727
  try {
1728
- const stats = await fs.stat(path);
1729
- total += stats.size;
1730
- if (stats.isDirectory() && !stats.isSymbolicLink()) {
1728
+ const stats = await fs.lstat(path);
1729
+ if (stats.isDirectory()) {
1731
1730
  const dirents = await fs.readdir(path);
1732
1731
  for (const dirent of dirents) {
1733
1732
  total += await getFolderSizeInternal(join(path, dirent));
1734
1733
  }
1734
+ } else {
1735
+ total += stats.size;
1735
1736
  }
1736
1737
  } catch {
1737
1738
  return 0;
@@ -1894,6 +1895,12 @@ const getFileHashes = async uris => {
1894
1895
  await flush();
1895
1896
  return hashes;
1896
1897
  };
1898
+ const getFileSize = async uri => {
1899
+ assertUri(uri);
1900
+ const path = fileURLToPath(uri);
1901
+ const stats = await fs.stat(path);
1902
+ return stats.size;
1903
+ };
1897
1904
  const writeFile = async (uri, content, encoding = Utf8) => {
1898
1905
  try {
1899
1906
  assertUri(uri);
@@ -2160,6 +2167,7 @@ const commandMap = {
2160
2167
  'FileSystem.forceRemove': forceRemove,
2161
2168
  'FileSystem.getFileHash': getFileHash,
2162
2169
  'FileSystem.getFileHashes': getFileHashes,
2170
+ 'FileSystem.getFileSize': getFileSize,
2163
2171
  'FileSystem.getFolderSize': getFolderSize,
2164
2172
  'FileSystem.isReadonly': isReadonly,
2165
2173
  'FileSystem.mkdir': mkdir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-system-process",
3
- "version": "5.16.1",
3
+ "version": "5.17.1",
4
4
  "description": "File System Process",
5
5
  "keywords": [
6
6
  "Lvce Editor",