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

[BUG] If drive mounted as folder, it checks root drive size instead of mounted folder size #573

Open
akademik opened this issue May 19, 2021 · 3 comments

Comments

@akademik
Copy link

I have lots of hard drives connected to my PC, thus I prefer having them mounted to folder rather than drive letters.

My DEST mounting structure is similar to:
C:/MountedPoints/1TB_HDD_No1
C:/MountedPoints/1TB_HDD_No2
C:/MountedPoints/1TB_HDD_No3
C:/MountedPoints/1TB_HDD_No4
...

My PLOTTER mounting structure is similar to:
C:/MountedPoints/PLOTTER1
C:/MountedPoints/PLOTTER2
...

In the manager.py view it shows the sizes similar to:
plotter: C: 300GB
plotter: C: 300GB
dest: C: 300GB

@baizuchong-net
Copy link

无法自动识别剩余空间,停止该目录绘图。

@bhuber
Copy link

bhuber commented May 23, 2021

I unfortunately have no time on my hands to submit a PR (maybe I will later), but I too encountered this bug and have a pretty reasonable workaround. It only applies to windows, and requires powershell be installed. If it fails to detect system drives properly using powershell, it silently falls back to the existing method.

The bug is caused by the call to psutil.disk_partitions(all=True) not returning partitions mounted to folders instead of drive letters. There appears to be an open bug in psutil for this ( giampaolo/psutil#1598 ), so once its fixed this workaround should no longer be necessary. The workaround is to use a powershell command to find the drive mount points instead.

In <swar-root>\plotmanager\library\utilities\processes.py replace the function get_system_drives with the following definition:

def get_system_drives():
    drives = []
    if is_windows():
        # psutil has an open bug where it doesn't properly find mountpoints for drives mounted to folders but not letters
        # https://github.com/giampaolo/psutil/issues/1598
        p = subprocess.run(
            ['powershell', '-command', 'Get-WmiObject Win32_Volume | Format-Table Name'],
            capture_output=True)
        if p.returncode == 0:
            # Output first lines are "Name" and "----", then real list of drives
            drives = [path.decode('utf-8') for path in p.stdout.split()[2:]]
            return drives
            
    for disk in psutil.disk_partitions(all=True):
        drive = disk.mountpoint
        if is_windows():
            drive = os.path.splitdrive(drive)[0]
        drives.append(drive)
    drives.sort(reverse=True)
    return drives

This patch has fixed the issue on my machine. It's also worth noting this issue is more than just a reporting bug - if you have skip_full_destinations = true in your config.yaml, new plots won't start if it thinks they would take up too much space on your root drive. For example, if you have < 100GB free in your root drive, new plots won't be started at all since it calculates using that free space rather than the real free space for the drive mounted in a subdirectory.

@Spiraldeath
Copy link

The other problem with this is it just says Dest C:\ , which mounted folder is the plot going to. I have no way of knowing which plot is going where. It has actually made this awesome program almost useless.

10 plots running and no idea without opening the log files where they are going, which has lead to multiple mishaps.

cheers

Lee

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

No branches or pull requests

4 participants