Skip to content

Fix temp files on Windows#199

Merged
rafaeltonholo merged 1 commit intorafaeltonholo:mainfrom
walterbrebels:windows-fix
Feb 18, 2026
Merged

Fix temp files on Windows#199
rafaeltonholo merged 1 commit intorafaeltonholo:mainfrom
walterbrebels:windows-fix

Conversation

@walterbrebels
Copy link
Copy Markdown
Contributor

@walterbrebels walterbrebels commented Jan 29, 2026

Fixes #174

Summary by CodeRabbit

  • Refactor
    • Build plugin now accepts and propagates a configurable temporary directory for SVG parsing, ensuring per-task temp folders are created under the provided base path for more consistent, isolated and controllable temporary file handling during builds.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Threads a base temporary directory from the Gradle task through DependencyModule into the worker parameters; the worker constructs per-execution temp subpaths from that base and TempFileWriter is instantiated with the provided temp directory path.

Changes

Cohort / File(s) Summary
Dependency injection
svg-to-compose-gradle-plugin/src/main/kotlin/dev/tonholo/s2c/gradle/internal/inject/DependencyModule.kt
Added tempDirectory: File constructor parameter and pass tempDirectory.toOkioPath() into TempFileWriter construction.
Task wiring
svg-to-compose-gradle-plugin/src/main/kotlin/dev/tonholo/s2c/gradle/tasks/ParseSvgToComposeIconTask.kt
Provide temporaryDir to DependencyModule and set parameters.tempDirPath when submitting the worker.
Worker parameters
svg-to-compose-gradle-plugin/src/main/kotlin/dev/tonholo/s2c/gradle/tasks/worker/IconParsingParameters.kt
Added val tempDirPath: Property<String> to the worker parameter interface.
Worker action
svg-to-compose-gradle-plugin/src/main/kotlin/dev/tonholo/s2c/gradle/tasks/worker/IconParsingWorkAction.kt
Resolve the run-specific temp directory by joining parameters.tempDirPath (base) with the UUID subpath instead of a hard-coded relative path.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Task as Gradle Task
participant DI as DependencyModule
participant Worker as Gradle Worker
participant Action as IconParsingWorkAction
participant TempWriter as TempFileWriter
Task->>DI: instantiate with temporaryDir (File)
DI->>Worker: provide dependencies (includes TempFileWriter with tempDirectory.toOkioPath())
Task->>Worker: submit work with parameters.tempDirPath = temporaryDir.absolutePath
Worker->>Action: execute with parameters
Action->>TempWriter: construct per-run tempDir = join(parameters.tempDirPath, UUID)
Action->>TempWriter: perform temp file operations

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses issue #174 by passing temporary directory paths through the dependency injection chain and modifying worker parameters, but lacks evidence of creating .s2c directories, making TempFileWriter/FileDeleter robust, or adding regression tests. Ensure the .s2c directory is created before use, make TempFileWriter.clear and FileDeleter.deleteRecursively null-safe, and add regression tests covering the scenario when .s2c folder is absent.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix temp files on Windows' clearly indicates the primary change addresses Windows-specific temporary file handling issues.
Out of Scope Changes check ✅ Passed All changes focus on plumbing temporary directory paths through the dependency injection and worker parameter system, which is directly scoped to addressing temporary file handling issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
svg-to-compose-gradle-plugin/src/main/kotlin/dev/tonholo/s2c/gradle/tasks/ParseSvgToComposeIconTask.kt (1)

56-66: Move temporaryDir access from initialization to task execution.

Accessing temporaryDir during task initialization (line 56-66) creates a race condition with gradle clean. Per Gradle's design, gradle clean can delete build/tmp after the configuration phase, leaving the task with a stale directory reference at execution time. Move the tempDirectory parameter into the @TaskAction method or use lazy initialization to avoid this. While TempFileWriter does auto-create directories via createDirectories(), relying on this masks the underlying issue of accessing temporaryDir too early in the build lifecycle.

@rafaeltonholo rafaeltonholo self-requested a review February 18, 2026 22:12
Copy link
Copy Markdown
Owner

@rafaeltonholo rafaeltonholo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing this issue!

@rafaeltonholo rafaeltonholo merged commit 3efddea into rafaeltonholo:main Feb 18, 2026
4 checks passed
@walterbrebels
Copy link
Copy Markdown
Contributor Author

Thank you for accepting this PR. Is it possible to release a new version with the changes?

@rafaeltonholo
Copy link
Copy Markdown
Owner

Hi @walterbrebels, sorry for the delay, I'm not having too much time to check this project rn. There are a few other things I wanted to add before publishing a new version, but I'm going to try publishing it soon!

@rafaeltonholo
Copy link
Copy Markdown
Owner

Hi @walterbrebels, sorry for the delay, I'm not having too much time to check this project rn. There are a few other things I wanted to add before publishing a new version, but I'm going to try publishing it soon!

@walterbrebels, I believe this will take way more time than I was expecting. I've published a new version 2.1.3 with your fix.

Sorry for keeping you waiting!

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.

Gradle plugin fails to create .s2c directory

2 participants