Skip to content
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

fix: unlink zip file in case of exceptions #492

Merged
merged 10 commits into from
Nov 6, 2023

Conversation

pribi
Copy link
Contributor

@pribi pribi commented Nov 1, 2023

Ticket: https://oat-sa.atlassian.net/browse/ADF-961

What's Changed

  • In case of Asset Export errors, the leftover zip file causes problems on the next Asset Export retry. In case of errors, delete the leftover zip file in order to prevent hidden bugs.

TODO

  • Unit tests
  • E2E tests
  • Update composer with packages

How to test

  • Create a new Passage Asset.
  • In Authoring Edit the Asset and embed and image.
  • Delete the embedded image - so there will be a broken link in the Asset.
  • Try to Export the Asset.
  • You should be able to notice the errors.
  • If you retry to Export the same Asset, you should be able to notice the errors, but no leftover zip file is provided for download.
    error

@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (274bb36) 37.47% compared to head (385df63) 37.64%.
Report is 9 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #492      +/-   ##
=============================================
+ Coverage      37.47%   37.64%   +0.17%     
- Complexity       795      797       +2     
=============================================
  Files             96       96              
  Lines           2874     2882       +8     
=============================================
+ Hits            1077     1085       +8     
  Misses          1797     1797              
Files Coverage Δ
model/ZipExporter.php 39.56% <83.33%> (+5.82%) ⬆️

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

$baseDir = tao_helpers_Export::getExportPath();
$path = $baseDir . '/' . $filename . '.zip';

$zip = new ZipArchive();
if ($zip->open($path, ZipArchive::CREATE) !== true) {
throw new common_Exception('Unable to create zipfile ' . $path);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible that your issue also happen here?

Copy link
Contributor

@Karol-Stelmaczonek Karol-Stelmaczonek left a comment

Choose a reason for hiding this comment

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

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • [] Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

Copy link
Contributor

@pnal pnal left a comment

Choose a reason for hiding this comment

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

Your tao-core PR seems to be a dependency for this fix.
So if it is, please, do not forget to update composer requirements in this repo according tao-core version supposed to be released.

@pribi
Copy link
Contributor Author

pribi commented Nov 5, 2023

Your tao-core PR seems to be a dependency for this fix. So if it is, please, do not forget to update composer requirements in this repo according tao-core version supposed to be released.

Thank you for the notice, I updated component dependencies in composer.json.

Copy link

github-actions bot commented Nov 6, 2023

Version

Target Version 12.40.0
Last version 12.39.1

There are 0 BREAKING CHANGE, 3 features, 5 fixes

@pribi pribi merged commit b22a33f into develop Nov 6, 2023
4 of 5 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.

5 participants