Skip to content

fix(lottie): Prevent SameFileError when exporting assets already in the images directory - #3506

Merged
ice0 merged 1 commit into
synfig:masterfrom
Stargazer10101:development
Mar 6, 2025
Merged

ice0 merged 1 commit into
synfig:masterfrom
Stargazer10101:development

Conversation

@Stargazer10101

@Stargazer10101 Stargazer10101 commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor

This PR fixes the issue where exporting animations to Lottie format fails when imported assets are already located in the images subdirectory. The error occurs because shutil.copy throws a SameFileError when attempting to copy a file to itself.
Changes:
Added a try-except block to handle shutil.SameFileError when copying assets to the images directory.
Ensured that file metadata is only copied if the file copy operation succeeds.
Skipped redundant copying when the source and destination files are the same.
Fixes #3471

@Stargazer10101
Stargazer10101 force-pushed the development branch 2 times, most recently from 2779bd0 to 1afd602 Compare March 5, 2025 11:05
@Stargazer10101 Stargazer10101 changed the title Fix: Prevent SameFileError when exporting assets already in the images directory fix: Prevent SameFileError when exporting assets already in the images directory Mar 5, 2025
@github-actions

github-actions Bot commented Mar 5, 2025

Copy link
Copy Markdown

Thank you for attempting to improve your contribution description!
Below is how your updated contribution will appear in Synfig's release notes. Review it and make further improvements until you're satisfied!

🐞 Bug Fixes

  • Prevent SameFileError when exporting assets already in the images directory

    Related issue: (#3471)
    This PR fixes the issue where exporting animations to Lottie format fails when imported assets are already located in the images subdirectory. The error occurs because shutil.copy throws a SameFileError when attempting to copy a file to itself.
    Changes:
    Added a try-except block to handle shutil.SameFileError when copying assets to the images directory.
    Ensured that file metadata is only copied if the file copy operation succeeds.
    Skipped redundant copying when the source and destination files are the same.

@rodolforg

rodolforg commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor

Thank you for helping us to solve this issue!

Instead of "Related issue:" at the beginning of the PR description, write it at the last line with the words "Close #", "Closes #", "Fix #" or "Fixes #".

We are using Conventional Commits for a while. The PR and commit 'titles' should not start in upper case.

@github-actions

github-actions Bot commented Mar 5, 2025

Copy link
Copy Markdown

Thank you for attempting to improve your contribution description!
Below is how your updated contribution will appear in Synfig's release notes. Review it and make further improvements until you're satisfied!

🐞 Bug Fixes

  • Prevent SameFileError when exporting assets already in the images directory

    This PR fixes the issue where exporting animations to Lottie format fails when imported assets are already located in the images subdirectory. The error occurs because shutil.copy throws a SameFileError when attempting to copy a file to itself.
    Changes:
    Added a try-except block to handle shutil.SameFileError when copying assets to the images directory.
    Ensured that file metadata is only copied if the file copy operation succeeds.
    Skipped redundant copying when the source and destination files are the same.
    Fixes #3471

@Stargazer10101

Copy link
Copy Markdown
Contributor Author

Hey @rodolforg thanks for suggesting corrections. Will follow the conventional commits hereafter. Apologies for multiple forced pushes.

@ice0

ice0 commented Mar 5, 2025

Copy link
Copy Markdown
Collaborator

Apologies for multiple forced pushes.

No issue here, it's ok.

@ice0 ice0 changed the title fix: Prevent SameFileError when exporting assets already in the images directory fix(lottie): Prevent SameFileError when exporting assets already in the images directory Mar 6, 2025
@github-actions

github-actions Bot commented Mar 6, 2025

Copy link
Copy Markdown

Thank you for attempting to improve your contribution description!
Below is how your updated contribution will appear in Synfig's release notes. Review it and make further improvements until you're satisfied!

🐞 Bug Fixes

  • (Lottie Related) Prevent SameFileError when exporting assets already in the images directory

    This PR fixes the issue where exporting animations to Lottie format fails when imported assets are already located in the images subdirectory. The error occurs because shutil.copy throws a SameFileError when attempting to copy a file to itself.
    Changes:
    Added a try-except block to handle shutil.SameFileError when copying assets to the images directory.
    Ensured that file metadata is only copied if the file copy operation succeeds.
    Skipped redundant copying when the source and destination files are the same.
    Fixes #3471

@ice0
ice0 merged commit 7b1b807 into synfig:master Mar 6, 2025
@ice0

ice0 commented Mar 6, 2025

Copy link
Copy Markdown
Collaborator

Merged. Thank you!

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.

[Lottie exporter] Cannot export if an imported asset is in the 'images' subdirectory

3 participants