Skip to content

This closes #2024, add TempDir field in the Options data type (#2024) #2163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 25, 2025

Conversation

mengpromax
Copy link
Contributor

@mengpromax mengpromax commented Jun 23, 2025

Change-Id: I96e24738982be893c8a52783069221b9abeff2cf

PR Details

  1. add specific temp dir option to excelize file options.
  2. when writing excel using streaming writer or read excel to load data to tmp file, it will use specific temp dir or default os.TempDir() to place temp file.

Description

Close #2024, add temp dir file option.

Related Issue

#2024

Motivation and Context

  1. when we use excelize streaming writer to write excel in our production pod, we meet that /tmp mountion is small, so we need this feature to change the temp file directory.

How Has This Been Tested

  1. UT.
  2. Test in our prod env.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Change-Id: I96e24738982be893c8a52783069221b9abeff2cf
Signed-off-by: mengzhongyuan <[email protected]>
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.23%. Comparing base (d434acd) to head (bb63356).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2163   +/-   ##
=======================================
  Coverage   99.23%   99.23%           
=======================================
  Files          32       32           
  Lines       30378    30379    +1     
=======================================
+ Hits        30147    30148    +1     
  Misses        153      153           
  Partials       78       78           
Flag Coverage Δ
unittests 99.23% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

mengzhongyuan added 2 commits June 23, 2025 23:54
Change-Id: Ia9dd626e88b9540afe8c1077205c400cbe40c0af
Signed-off-by: mengzhongyuan <[email protected]>
Change-Id: I9c26214ccf8f48aa2c56356a2ff75364e445459b
Signed-off-by: mengzhongyuan <[email protected]>
@mengpromax mengpromax changed the title WIP feat: support specific temp dir (#2024) feat: support specific temp dir (#2024) Jun 24, 2025
@xuri xuri added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2025
@xuri xuri moved this to Features in Excelize v2.10.0 Jun 24, 2025
@xuri xuri requested a review from Copilot June 25, 2025 02:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to specify a custom temporary directory for excelize operations, ensuring that streaming writer temp files and unzipped files are created in the desired location rather than the default OS temporary directory.

  • Introduces a new Options field (TmpDir) and updates file creation functions to utilize it.
  • Updates tests to validate behavior when using a specific temp directory.
  • Modifies several core files (stream.go, rows.go, lib.go, excelize.go) and relevant tests (stream_test.go, lib_test.go) to support this functionality.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
stream_test.go Added tests to verify that temp files are created and then removed based on the provided temp directory.
stream.go Updated the streaming writer to set a custom temp directory when provided.
rows.go Uses the custom temp directory for creating shared string temp file.
lib_test.go Added unzip-related test to validate temp file creation in a specific directory.
lib.go Updated unzipToTemp to use the custom temp directory if provided.
excelize.go Extended Options to include the TmpDir property for temporary file location.

Change-Id: I227385384f81dba8cb013315896e6e93a6412814
Signed-off-by: mengzhongyuan <[email protected]>
Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@xuri xuri added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 25, 2025
@xuri xuri changed the title feat: support specific temp dir (#2024) This closes #2024, add TempDir field in the Options data type (#2024) Jun 25, 2025
@xuri xuri merged commit 55e152f into qax-os:master Jun 25, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Features
Development

Successfully merging this pull request may close these issues.

Flexability in temporary folder in StreamWriter files
2 participants