Skip to content

Unnecessary disk write #8

@xayaank

Description

@xayaank

file created to reserve name:
fd = os.open(candidate, os.O_CREAT | os.O_EXCL | os.O_WRONLY)

Later:
with open(out_path, "wb") as f:
f.write(...)

Problems:
empty file created first
Then overwritten
program crash between steps = leftover empty file still exists
Also unnecessary disk write

Better approach:
Compute unique name without creating files, OR open with O_EXCL + write immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions