-
Notifications
You must be signed in to change notification settings - Fork 25
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 Crash when Calculation of size of deleted dirs is asked for #143
Conversation
Currently using python 3.10, at first I thought the default was maybe changed but according to this the default is the same in 3.6: |
with tempfile.NamedTemporaryFile(mode="w") as tmp_file: | ||
for directory in dirs: | ||
tmp_file.write(directory + "\x00") |
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.
I am wondering if this is the correct solution. Here we write a list of directories to a file. The directories should be delimited with zero-bytes "\x00"
to work with the option --files0-from
(cf. https://man7.org/linux/man-pages/man1/du.1.html)
If I see it correctly, the default mode is binary write and you change it to text write. With your proposal I think the lines are delimited with the characters "\x00". So then the du command below should not find the corresponding folders?
I think rather should we change what is written to binary:
with tempfile.NamedTemporaryFile(mode="w") as tmp_file: | |
for directory in dirs: | |
tmp_file.write(directory + "\x00") | |
with tempfile.NamedTemporaryFile() as tmp_file: | |
for directory in dirs: | |
tmp_file.write(directory.encode() + b"\x00") |
(But please test both variants)
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.
so with my variant I got some result (which is hard to confirm whether correct but looked reasonable)
will test yours now
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.
it seems that \x
will make the next two characters be interpreted as a binary value. So your solution works fine.
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.
i just tested your variant aswell, both produce the same results. Feel free to merge whatever you prefer.
with tempfile.NamedTemporaryFile(mode="w") as tmp_file: | ||
for directory in dirs: | ||
tmp_file.write(directory + "\x00") |
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.
it seems that \x
will make the next two characters be interpreted as a binary value. So your solution works fine.
When calling the current code it crashes with:
This fixes this error. Tbh. I am not sure how this has worked before?