Skip to content

Commit

Permalink
fix: diskusage, local dir counter, bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Nov 19, 2024
1 parent bf950b6 commit 649b258
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
26 changes: 16 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@
"dependencies": {
"@filen/network-drive": "^0.9.30",
"@filen/s3": "^0.2.44",
"@filen/sdk": "^0.1.177",
"@filen/sdk": "^0.1.181",
"@filen/sync": "^0.1.80",
"@filen/web": "^0.1.58",
"@filen/web": "^0.1.61",
"@filen/webdav": "^0.2.59",
"axios": "^0.28.1",
"cors": "^2.8.5",
"diskusage-ng": "^1.0.4",
"electron-updater": "^6.4.0-alpha.1",
"express": "^4.19.2",
"fast-glob": "^3.3.2",
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export async function getLocalDirectorySize(path: string): Promise<{
followSymbolicLinks: false,
deep: Infinity,
fs,
suppressErrors: false,
suppressErrors: true,
stats: true,
unique: true,
objectMode: true
Expand All @@ -417,7 +417,7 @@ export async function getLocalDirectorySize(path: string): Promise<{

const entryItem = entry as unknown as Required<Entry>

if (entryItem.dirent.isFile()) {
if (entryItem.stats && entryItem.dirent?.isFile()) {
size += entryItem.stats.size
}

Expand Down
9 changes: 6 additions & 3 deletions src/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { type FilenDesktopConfig, type WorkerMessage, type WorkerInvokeChannel }
import WebDAV from "./webdav"
import S3 from "./s3"
import NetworkDrive from "./networkDrive"
import diskusage from "diskusage-ng"
import { serializeError, getLocalDirectorySize } from "../utils"
import pathModule from "path"
import fs from "fs-extra"
Expand Down Expand Up @@ -94,7 +93,7 @@ export class Worker {
await fs.ensureDir(cachePath)

return await new Promise<number>(resolve => {
diskusage(cachePath, (err, usage) => {
fs.statfs(cachePath, (err, stats) => {
if (err) {
this.logger.log("error", err, "worker.networkDriveAvailableCacheSize")
this.logger.log("error", err)
Expand All @@ -104,7 +103,11 @@ export class Worker {
return
}

resolve(usage.available)
const blockSize = stats.bsize
const availableBlocks = stats.bavail
const freeSpace = availableBlocks * blockSize

resolve(freeSpace)
})
})
}
Expand Down

0 comments on commit 649b258

Please sign in to comment.