Skip to content

Bug: Fragile hardcoded 'XXXX' directory in geographies.R #219

@dshkol

Description

@dshkol

Description

In R/geographies.R around lines 60-66, there is a hardcoded temporary directory name "XXXX" used for nested zip extraction:

tmp_dir <- file.path(geo_base_path,"XXXX")

Issues

  1. Collision risk: If extraction is interrupted or fails, the "XXXX" directory may persist and cause issues on subsequent runs
  2. Non-descriptive name: Makes debugging harder
  3. Not using tempdir(): Standard R practice is to use tempfile() or tempdir() for temporary directories

Suggested Fix

Replace with:

tmp_dir <- tempfile(pattern = "cancensus_geo_", tmpdir = geo_base_path)

Or use withr::local_tempdir() for automatic cleanup.

Impact

Low - rare edge case, but could cause confusing errors if a user has an existing "XXXX" directory or if extraction fails mid-process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions