Skip to content
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

Do not list devices with a zero size #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dennis1248
Copy link

This will avoid block devices with a zero size from being listed. Imagine devices such as SD card readers.

@143mailliw
Copy link

I'm not so sure we want to do that - installing on an SD card is a very common use case for handheld devices.

@dennis1248
Copy link
Author

I'm not so sure we want to do that - installing on an SD card is a very common use case for handheld devices.

SD cards will still be listed, just not devices with a zero size such as card readers. Card readers may appear as a block device even when no card is inserted.

sdc           8:32   1    0B  0 disk 

@@ -35,6 +35,8 @@ func get_available_disks() -> Array[Disk]:
if not line.contains("disk"):
continue
var parts := line.split(" ", false, 3)
if parts[2] as int == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output of lsblk --list -n -o name,type,size,model will show the size along with a unit (e.g. 1G, 0B). This should be updated to match on that pattern, instead of casting to an int.

E.g.

Suggested change
if parts[2] as int == 0:
if parts[2] == "0B":

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks!

I observed that in GDscript if you pass it a string as int it will remove all non-int characters, is my observation correct? I am unable to replicate the behaviour in Python.

@dennis1248 dennis1248 requested a review from ShadowApex October 4, 2023 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants