Skip to content

Fix: Only create mismatch directory when files are actually written#5

Merged
jaxels20 merged 5 commits into
masterfrom
copilot/fix-4
Aug 28, 2025
Merged

Fix: Only create mismatch directory when files are actually written#5
jaxels20 merged 5 commits into
masterfrom
copilot/fix-4

Conversation

Copilot AI commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

The datarecorder was creating mismatch directories even when no mismatch files needed to be written, resulting in empty folders accumulating on CI systems.

Problem

The determine_mismatch_dir() function immediately created a directory in /tmp/cppmismatch-N/ whenever a mismatch was detected, regardless of whether any files would actually be written to it. This meant that:

  • The default mismatch handler (which doesn't write files) still created empty directories
  • Any interruption during mismatch handling could leave empty directories behind
  • CI systems accumulated unnecessary empty folders over time

Solution

Split the directory path determination from directory creation:

  1. Renamed determine_mismatch_dir() to determine_mismatch_path() - now only returns the path without creating directories
  2. Enhanced write_data() with lazy directory creation - automatically creates parent directories when files are actually written using std::filesystem::create_directories()

Example

Before this fix:

// Always creates /tmp/cppmismatch-0/ even if no files are written
std::filesystem::path mismatch_dir = determine_mismatch_dir();
// Directory exists but may remain empty

After this fix:

// Only determines the path, no directory created yet
std::filesystem::path mismatch_dir = determine_mismatch_path();
// Directory is created only when write_data() is called
write_data(mismatch_dir / "diff.html", html_content);

This ensures mismatch directories are created only when they actually contain files, eliminating the accumulation of empty directories on CI systems.

Fixes #4.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

@mortenvp 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: mortenvp <1279584+mortenvp@users.noreply.github.com>
Copilot AI changed the title [WIP] Only create mismatch directory when needed Fix: Only create mismatch directory when files are actually written Aug 18, 2025
Copilot AI requested a review from mortenvp August 18, 2025 12:33
@jaxels20 jaxels20 marked this pull request as ready for review August 28, 2025 13:02
@jaxels20 jaxels20 merged commit 695f845 into master Aug 28, 2025
13 checks passed
@jaxels20 jaxels20 deleted the copilot/fix-4 branch August 28, 2025 13:09
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.

Only create mismatch directory when needed

3 participants