crowdin-cli icon indicating copy to clipboard operation
crowdin-cli copied to clipboard

delete-obsolete deletes existing files when multiple file configurations present with the same destination

Open coyoteecd opened this issue 3 years ago • 0 comments

Describe the bug

I'm using crowdin-cli to upload documentation files for our project. These have a specific file structure on disk, which forces us to have a configuration with multiple files entries, that copy files in the same destination:

  • docs/en/index.md
  • docs/en/locale.yml

When using the --delete-obsolete parameter in combination with a configuration file that has multiple files entries, both of the source files are deleted as obsolete, even though they exist on disk. This causes the upload to fail as well.

To Reproduce Steps to reproduce the behavior:

  1. Configuration file:
#
# Choose file structure in crowdin
# e.g. true or false
#
"preserve_hierarchy": true

#
# Files configuration
#
files: [
  {
    "source" : "/docs/en/index.md",
    "dest": "/app/%original_path%/%original_file_name%",
    "translation" : "/app/docs/%two_letters_code%/%original_file_name%"
  },
  {
    "source" : "/docs/en/locale.yml",
    "dest": "/app/%original_path%/%original_file_name%",
    "translation" : "/app/docs/%two_letters_code%/%original_file_name%"
  }
]
  1. Execute CLI command: crowdin upload sources -c localization.yml --delete-obsolete --identity $CROWDIN_CREDENTIALS --dryrun
  2. Following output is logged:
20:10:50  + crowdin upload sources -c localization.yml --delete-obsolete --identity **** --dryrun
20:10:55  ✔️  Obsolete file 'app/docs/en/index.md'
20:10:55  ✔️  Obsolete file 'app/docs/en/locale.yml'
20:10:55  ✔️  File 'docs/en/index.md'
20:10:55  ✔️  File 'docs/en/locale.yml'

Expected behavior I expect the obsolete detection to act at project-level (so, calculate the diff between the union of files at all source entries and the union files at all dest entries, and not a union of diffs). In other words, the scenario above would not find any of the files obsolete.

Environment:

  • crowdin/cli:3.7.8 docker image

coyoteecd avatar May 18 '22 17:05 coyoteecd