mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #310] Zip file not properly closed after file write error #250
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#250
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @matthiasstraka on GitHub (Sep 24, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/310
Originally assigned to: @jmcnamara on GitHub.
I am having an issue with writing an xlsx file to a disk that is already full. A write error is reported (in _add_file_to_zip) but the corresponding zip file remains open when reporting the error to the caller of workbook_close. This prevents me from erasing a failed xlsx file.
How to reproduce:
@jmcnamara commented on GitHub (Sep 24, 2020):
Thanks for the report. I'll look into it.
@jmcnamara commented on GitHub (Sep 24, 2020):
Can you try the fix on the gh310 branch to see if it resolves your issue.
@matthiasstraka commented on GitHub (Sep 25, 2020):
Thanks, this looks better. Sorry for not fixing it myself as I do not have the time to check for side effects at the moment.
I would also suggest swapping
fclose(worksheet->file);andRETURN_ON_ERROR(err);in _write_worksheet_files and maybe callzipCloseFileInZip(self->zipfile);in the error paths of _add_file_to_zip or clean up zipfile in an approriate way.@jmcnamara commented on GitHub (Sep 25, 2020):
Good suggestions. I'll look into that.
@jmcnamara commented on GitHub (Sep 25, 2020):
I've force pushed an updated version onto the same branch: 2c8cf48
Try it out for your failing test case if you get a chance.
@matthiasstraka commented on GitHub (Sep 25, 2020):
I tested you commits and can happily report that both the current temporary file and the xlsx-zip file are closed when my disk runs full. Thus, I can delete the file after writing failed and no temporary files stay around. This issue is fixed for me.
@jmcnamara commented on GitHub (Sep 25, 2020):
Cool thanks for the feedback @matthiasstraka
I'll do a bit more testing and merge it up to main.
@jmcnamara commented on GitHub (Sep 25, 2020):
@matthiasstraka Thanks for testing.
There were still some possible, but unlikely, paths that could return an error without a cleanup. I think all of them are covered now.
When you get a chance can you test once more with the code on the same branch:
dfbc07cNo rush.
@jmcnamara commented on GitHub (Oct 2, 2020):
Fixed and merged to main. Thanks for the report.