Skip to content

Check get_folder_size_in_gb function in compute worker code #2222

@Didayolo

Description

@Didayolo

This recursion feels weird in compute_worker.py:

def get_folder_size_in_gb(folder):
    if not os.path.exists(folder):
        return 0
    total_size = os.path.getsize(folder)
    for item in os.listdir(folder):
        path = os.path.join(folder, item)
        if os.path.isfile(path):
            total_size += os.path.getsize(path)
        elif os.path.isdir(path):
            total_size += get_folder_size_in_gb(path)
    return total_size / 1000 / 1000 / 1000  # GB: decimal system (1000^3)

Is this function correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Post-itInternal ideas

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions