-
-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix du parameters on macOS #74
Conversation
src/services/linux-files.service.ts
Outdated
|
||
export class LinuxFilesService extends FileService { | ||
constructor(private streamService: StreamService) { | ||
super(); | ||
} | ||
|
||
getFolderSize(path: string): Observable<{}> { | ||
const du = spawn('du', ['-s', '-b', path]); | ||
const du = isOSMacOS() ? spawn('du', ['-s', path]) : spawn('du', ['-s', '-b', path]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the default is to return blocks. So this won’t give the right number on macOS (the reason for the original change to -b
). AFAIK the default block size is 512b.
My suggestion is to use -k
(kilobytes), and skip the bytes to kB call for macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comment @marcins! You mean use -k
instead of -s
on macOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, use -sk
I guess, since we're just interested in the summary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcins, you were absolutely right, it did not give the correct number on macOS.
Actually, the solution was much easier than what I initially tried with isOSMacOS
: We can use du -sk
on both Linux and macOS. :)
2dc190b
to
a828828
Compare
Thanks for the PR @friederbluemle, I appreciate your contribution 👏 However, it resolves #70 and #67, it produces other drawbacks related with the reported size saved (as I commented here), because it's a non "real size". If you check the sizes reported using With nothing more to add, LGTM 👍 |
I think @zaldih (and @NyaGarcia?) should comment here about this because he was who found the bug 👀 |
Thanks for your comment @tonivj5 - Definitely agree with you that this might not be the final fix. If you have a suggestion on how to address it in this PR please let me know. Otherwise we can merge it and you can submit a follow-up PR? This PR is just the bare minimum to fix the current issue on macOS (i.e. npkill not working at all). I did check your comment about the sizing problem, and tried to reproduce it locally. Could you explain a bit more how exactly the reported size deviates from the "real size"? Thank you! |
Totally I agree with you
I think this article is going to explain it better than me. However, both sizes are "real", we have noticed that I'm not completely sure, but I remember @zaldih had or saw an issue for that reason. Maybe, we was doing the wrong way here, but I'm not very confident now 🙊 |
a828828
to
2566e9a
Compare
@tonivj5 - Okay, that makes sense. So it sounds like It sounds to me the "exact" byte size ( For example: Consider a directory with 1,000 files in it. Each one only contains a single character (1 Byte). What should a tool report if asked for the size of the directory? 1,000 Bytes? Not really... The disk space the directory occupies is much higher: With a disk block size of 4096 Bytes it is around 4 Megabytes! Since |
Btw, I just rebased my PR head branch on top of
|
Btw, if you want to check the block size of your disk on macOS:
And on Linux (replace
|
Yeah, I agree 👍 @zaldih has the last word about this, awaiting for his review 👀 |
Hi folks, sorry for the delay in answering 😅 |
Fixes #70 by not using the unsupported
-b
flag on macOS. Instead, we use-k
which is supported on both Linux and macOS. Since the reported value is already in kilobytes, we no longer have to convert it in npkill.Also fixes #67 (same issue).