Skip to content

Commit 816fd1c

Browse files
authored
Add md5 of repositories to TMX filename (fixes #841) (#846)
1 parent 1de6a80 commit 816fd1c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

app/models/tmx_downloading.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
$missing_repos_count = $repos_count = 0;
66
$strings = ['en-US' => [], $locale => []];
77

8+
$requested_repositories = '';
89
foreach ($repos as $repo) {
910
if (isset($_GET[$repo])) {
11+
$requested_repositories .= $repo;
1012
$cache_file_english = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);
1113

1214
if ($cache_file_english) {
@@ -47,16 +49,13 @@ function ($e) {
4749
$empty_TMX = $repos_count == 0;
4850

4951
// Generate the TMX file
52+
$content = $check['tmx_format'] == 'normal'
53+
? TMX::create($strings, $locale, 'en-US')
54+
: TMX::createOmegat($strings, $locale, 'en-US');
5055

51-
if ($check['tmx_format'] == 'normal') {
52-
$content = TMX::create($strings, $locale, 'en-US');
53-
$target_file = 'mozilla_en-US_' . $locale . '.tmx';
54-
} else {
55-
$content = TMX::createOmegat($strings, $locale, 'en-US');
56-
$target_file = 'mozilla_en-US_' . $locale . '_forOmegaT.tmx';
57-
}
58-
59-
$target_file_path = WEB_ROOT . 'download/' . $target_file;
56+
$tmx_id = md5($requested_repositories);
57+
$target_file_name = "mozilla_en-US_{$locale}_{$tmx_id}_{$check['tmx_format']}.tmx";
58+
$target_file_path = WEB_ROOT . "download/{$target_file_name}";
6059

6160
unset($strings);
6261

app/views/tmx_downloading.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<span id="download">
2626
<?php
2727
if (!$empty_TMX) {
28-
echo '<a class="button" href="/download/' . $target_file . '">Download</a> or ';
28+
echo '<a class="button" href="/download/' . $target_file_name . '">Download</a> or ';
2929
}
3030
?>
3131
<a href="/downloads">Go back to TMX creation page</a>

0 commit comments

Comments
 (0)