Skip to content

Commit

Permalink
fix: source downloading when source and dest have different base name
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Jun 27, 2023
1 parent c4ad0af commit cb6e997
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void act(Outputter out, PropertiesWithFiles properties, ProjectClient cli
String translationPattern = TranslationsUtils.replaceDoubleAsterisk(fileBean.getSource(), fileBean.getTranslation(), filePathKey);
if (exportPattern == null || translationPattern.endsWith(exportPattern)) {
String sourceName = new java.io.File(fileBean.getSource()).getName();
if(sourceName.equals(new java.io.File(filePathKey).getName()) || SourcesUtils.containsPattern(sourceName)) {
if(sourceName.equals(new java.io.File(filePathKey).getName()) || SourcesUtils.containsPattern(sourceName) || searchPattern.contains(filePathKey)) {
filePaths2.add(filePathKey);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void testDifferentPatterns() throws IOException {
.addBuiltFileBean("/folder_2/android_4?.xml", "/%locale%/folder_2/%file_name%.xml")
.addBuiltFileBean("folder1/folder2/**/messages.json", "/folder1/folder2/**/%file_name%_%two_letters_code%.json", new ArrayList<>(), "/folder_on_crowdin/%original_path%/%file_name%.json")
.addBuiltFileBean("folder1/folder2/**/plugins.json", "/folder1/folder2/**/%file_name%_%two_letters_code%.json", new ArrayList<>(), "/folder_on_crowdin/%original_path%/%file_name%.json")
.addBuiltFileBean("foo_string.json", "/workdir/foo/string_%two_letters_code%.json", new ArrayList<>(), "/foo_string.json")
.setBasePath(project.getBasePath())
.setPreserveHierarchy(true)
.build();
Expand All @@ -149,6 +150,7 @@ public void testDifferentPatterns() throws IOException {
.addFile("android_4a.xml", "gettext", 107L, 204L, null, "/%locale%/folder_2/%file_name%.xml")
.addFile("messages.json", "json", 108L, 208L, null, "/folder1/folder2/nested/%file_name%_%two_letters_code%.json")
.addFile("plugins.json", "json", 109L, 208L, null, "/folder1/folder2/nested/%file_name%_%two_letters_code%.json")
.addFile("foo_string.json", "json", 110L, null, null, null)
.build());
URL urlMock = MockitoUtils.getMockUrl(getClass());
when(client.downloadFile(eq(101L)))
Expand All @@ -169,6 +171,8 @@ public void testDifferentPatterns() throws IOException {
.thenReturn(urlMock);
when(client.downloadFile(eq(109L)))
.thenReturn(urlMock);
when(client.downloadFile(eq(110L)))
.thenReturn(urlMock);

FilesInterface files = mock(FilesInterface.class);

Expand All @@ -186,6 +190,7 @@ public void testDifferentPatterns() throws IOException {
verify(client).downloadFile(eq(107L));
verify(client).downloadFile(eq(108L));
verify(client).downloadFile(eq(109L));
verify(client).downloadFile(eq(110L));
verifyNoMoreInteractions(client);

verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder_1/android.xml")), any());
Expand All @@ -197,6 +202,7 @@ public void testDifferentPatterns() throws IOException {
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder_2/android_4a.xml")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder1/folder2/nested/messages.json")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder1/folder2/nested/plugins.json")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/foo_string.json")), any());
verifyNoMoreInteractions(files);
}

Expand Down

0 comments on commit cb6e997

Please sign in to comment.