Skip to content

fix temp files cleanup#122

Merged
MichalFrends1 merged 2 commits into
mainfrom
fspes-112
May 8, 2026
Merged

fix temp files cleanup#122
MichalFrends1 merged 2 commits into
mainfrom
fspes-112

Conversation

@MatteoDelOmbra
Copy link
Copy Markdown
Contributor

@MatteoDelOmbra MatteoDelOmbra commented May 5, 2026

Review Checklist

  • Task version updated (x.x.0)
  • CHANGELOG.md updated
  • Solution builds
  • Warnings resolved (if possible)
  • Typos resolved
  • Tests cover new code
  • Description how to run tests locally added to README.md (if needed)
  • All tests pass locally

Summary by CodeRabbit

  • Refactor

    • Centralized temporary file handling for upload operations so all intermediate files are created in a task-specific temp directory and removed reliably.
  • Fix

    • Ensures temporary files are cleaned up on completion or error, preventing leftover temp-file accumulation during uploads.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e6b8cdf-25dc-4f78-9078-e4216be556a7

📥 Commits

Reviewing files that changed from the base of the PR and between 01449bc and ae2a108.

📒 Files selected for processing (3)
  • Frends.AzureBlobStorage.UploadBlob/CHANGELOG.md
  • Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob.csproj
  • Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/UploadBlob.cs
✅ Files skipped from review due to trivial changes (2)
  • Frends.AzureBlobStorage.UploadBlob/CHANGELOG.md
  • Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob.csproj
🚧 Files skipped from review as they are similar to previous changes (1)
  • Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/UploadBlob.cs

Walkthrough

A task-local temp directory is created at UploadBlob start, threaded through HandleUpload → AppendAny → GetStream and compression/re-encoding helpers for intermediate files, and removed in a finally block; changelog and project version updated.

Changes

Temp Directory Centralization

Layer / File(s) Summary
Utility Functions
UploadBlob.cs
Adds CreateTempDirectory(), CreateTempFilePath(tempDirectory), and CleanupTempDirectory(tempDirectory) to manage a per-task temp directory.
Main Upload Flow
UploadBlob.cs
UploadBlob now calls CreateTempDirectory(), passes tempDirectory into HandleUpload for file and directory uploads, and ensures CleanupTempDirectory(tempDirectory) in a finally block.
Upload Handler & Append Logic
UploadBlob.cs
HandleUpload signature updated to accept tempDirectory; it passes the directory to AppendAny. AppendAny now accepts tempDirectory and creates fallback intermediate files via CreateTempFilePath(tempDirectory) rather than system temp APIs.
Stream Building & Compression
UploadBlob.cs
GetStream, GetCompressedStream, GetReencodedStream, CreateCompressedBinaryStream, and CreateBinaryCopyStream accept tempDirectory and place intermediate artifacts inside it instead of using system temp files.
Changelog & Project
CHANGELOG.md, Frends.AzureBlobStorage.UploadBlob.csproj
Adds 4.1.0 changelog entry noting temp-file cleanup; bumps project <Version> from 4.0.0 to 4.1.0.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • MichalFrends1

Poem

🐰 I dug a neat little temp-burrow today,
All files in one safe place to stay.
Uploads hop in, then hop out with glee,
Cleanup's done — tidy as can be! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 cleanup' directly and clearly describes the main change: implementing proper cleanup of temporary files in the UploadBlob functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fspes-112

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/UploadBlob.cs`:
- Around line 191-192: The append-flow is using input.SourceFile which can be
empty for directory-mode uploads; update all calls to AppendAny to pass the
actual file path using fi.FullName instead of input.SourceFile (e.g., replace
the argument in AppendAny(appendBlobClient, blobName, input.SourceFile,
tempDirectory, cancellationToken) and the other two occurrences so they become
AppendAny(appendBlobClient, blobName, fi.FullName, tempDirectory,
cancellationToken)), ensuring the AppendAny invocation uses fi.FullName for
append operations.
- Around line 626-631: The CleanupTempDirectory method currently calls
Directory.Delete and can throw, which may mask upload results; change
CleanupTempDirectory(string tempDirectory) to perform a best-effort delete by
catching and ignoring (or logging) any exceptions from Directory.Delete so it
never throws (do not rethrow), and ensure it still returns void; reference the
method name CleanupTempDirectory and the call to Directory.Delete when locating
the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b04fbd57-640c-4282-b7fe-e00dd1701a2a

📥 Commits

Reviewing files that changed from the base of the PR and between 1eca46d and 01449bc.

📒 Files selected for processing (1)
  • Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/UploadBlob.cs

Comment on lines +191 to +192
fi = await AppendAny(appendBlobClient, blobName, input.SourceFile, tempDirectory,
cancellationToken);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the current file path in append flows (directory mode bug).

Line 191, Line 266, and Line 310 pass input.SourceFile to AppendAny. In directory uploads this can be empty, causing append-on-existing paths to fail. Pass fi.FullName instead.

Suggested fix
- fi = await AppendAny(appendBlobClient, blobName, input.SourceFile, tempDirectory,
+ fi = await AppendAny(appendBlobClient, blobName, fi.FullName, tempDirectory,
     cancellationToken);

- fi = await AppendAny(blobClient, blobName, input.SourceFile, tempDirectory, cancellationToken);
+ fi = await AppendAny(blobClient, blobName, fi.FullName, tempDirectory, cancellationToken);

- fi = await AppendAny(pageBlobClient, blobName, input.SourceFile, tempDirectory,
+ fi = await AppendAny(pageBlobClient, blobName, fi.FullName, tempDirectory,
     cancellationToken);

Also applies to: 266-266, 310-311

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Frends.AzureBlobStorage.UploadBlob/Frends.AzureBlobStorage.UploadBlob/UploadBlob.cs`
around lines 191 - 192, The append-flow is using input.SourceFile which can be
empty for directory-mode uploads; update all calls to AppendAny to pass the
actual file path using fi.FullName instead of input.SourceFile (e.g., replace
the argument in AppendAny(appendBlobClient, blobName, input.SourceFile,
tempDirectory, cancellationToken) and the other two occurrences so they become
AppendAny(appendBlobClient, blobName, fi.FullName, tempDirectory,
cancellationToken)), ensuring the AppendAny invocation uses fi.FullName for
append operations.

Copy link
Copy Markdown
Contributor

@MichalFrends1 MichalFrends1 left a comment

Choose a reason for hiding this comment

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

Update project version and changelog

@MichalFrends1 MichalFrends1 merged commit 4a42dfe into main May 8, 2026
4 checks passed
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.

2 participants