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

Detecting / deleting obsolete files not working #775

Closed
anbraten opened this issue Apr 26, 2024 · 8 comments · Fixed by #776
Closed

Detecting / deleting obsolete files not working #775

anbraten opened this issue Apr 26, 2024 · 8 comments · Fixed by #776
Labels

Comments

@anbraten
Copy link
Contributor

Describe the bug
Delete obsolete is not detecting deleted / non-existing file.

To Reproduce
Steps to reproduce the behavior:

  1. Configuration file:
preserve_hierarchy: true

files:
  # Docs Markdown files
  - source: '/test/en/**/*.md'
    translation: '/test/%two_letters_code%/**/%original_file_name%'
  1. tree test/:
test/
└── en
    ├── support.md
    └── test.md

2 directories, 2 files
  1. Execute CLI command: npx @crowdin/cli upload sources --token ... --project-id ... --delete-obsolete --no-auto-update
    Outputs:
✔️  Fetching project info     
⏭  File 'test/en/support.md'
⏭  File 'test/en/test.md'
✔️  No obsolete files were found
✔️  No obsolete directories found

image

  1. Rename file test/en/support.md => test/en/help.md
  2. Execute CLI command again: npx @crowdin/cli upload sources --token ... --project-id ... --delete-obsolete --no-auto-update
    Outputs:
✔️  Fetching project info     
⏭  File 'test/en/test.md'
⏭  File 'test/en/help.md'
✔️  No obsolete files were found
✔️  No obsolete directories found

image

Expected behavior
I expect the file test/en/support.md to be detected as obsolete and deleted on Crowdin afterwards as it does not exists locally anymore.

Environment:

  • OS: Ubuntu
  • Version 23.04
  • Cli: @crowdin/cli@3.19.2
@anbraten anbraten changed the title Delete obsolete not working as expected Detecting / deleting obsolete files not working Apr 26, 2024
@anbraten
Copy link
Contributor Author

anbraten commented Apr 26, 2024

Issue seems to be coming from the file exportPattern property being null in the following code section. Why is the export setting checked at all? Shouldn't deleting files only depend on the source path and the path it's saved in crowdin?

return exportPattern.equals(fileExportPattern != null ? Utils.normalizePath(fileExportPattern) : null);

image

@andrii-bodnar
Copy link
Member

Hi @anbraten, thanks for your input!

I suppose the exportPattern check is needed in cases where the local file path might be different from the uploaded file path in Crowdin. For example, in case of using preserve_hierarchy: false or dest parameters, the uploaded file path might be different from the original file path. Does this make sense?

@anbraten
Copy link
Contributor Author

Hi @andrii-bodnar,
thanks for the explanation. So exportPattern will be set in api in case I uploaded a file with preserve_hierarchy: false or dest options configured (couldn't find any explanation in the api docs)? Should I simply ignore in checkExportPattern if the api returned exportPattern is null?

@andrii-bodnar
Copy link
Member

CLI will always set the export pattern during the sources upload, even with preserve_hierarchy: false or dest options configured. In most cases, it will be the same as the translation pattern from the configuration file (except the cases with ** usage).

If the exportPattern is null - the file probably wasn't uploaded by the CLI and shouldn't be deleted as well by the --delete-obsolete option.

@anbraten
Copy link
Contributor Author

anbraten commented May 6, 2024

If the exportPattern is null - the file probably wasn't uploaded by the CLI and shouldn't be deleted as well by the --delete-obsolete option.

The file you can see in the previous screenshot I've uploaded using the cli first and then debugged a second upload where that file then has exportPattern set to null. Therefore I am not really sure if this statement is correct. Do you have any suggestion how we can do further tests here?

@andrii-bodnar
Copy link
Member

andrii-bodnar commented May 7, 2024

@anbraten could you please provide a test project (the crowdin.yml configuration file, corresponding source files structure) and steps to reproduce that I can try on my side?

@anbraten
Copy link
Contributor Author

anbraten commented May 7, 2024

@andrii-bodnar Sure, here is a pretty basic sample: https://github.com/anbraten/repro-crowdin-delete-obsolete. Added a readme with some steps what I've done.

@andrii-bodnar
Copy link
Member

@anbraten thank you, I was able to reproduce the issue. Could you please take a look at my comment in the PR and check the failed CI? It looks like the new test case is not adapted to work in the Windows environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants