Skip to content

Commit

Permalink
Add md5 of repositories to TMX filename (fixes #841) (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo authored Feb 1, 2017
1 parent 1de6a80 commit 816fd1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions app/models/tmx_downloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
$missing_repos_count = $repos_count = 0;
$strings = ['en-US' => [], $locale => []];

$requested_repositories = '';
foreach ($repos as $repo) {
if (isset($_GET[$repo])) {
$requested_repositories .= $repo;
$cache_file_english = Utils::getRepoStrings(Project::getReferenceLocale($repo), $repo);

if ($cache_file_english) {
Expand Down Expand Up @@ -47,16 +49,13 @@ function ($e) {
$empty_TMX = $repos_count == 0;

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

if ($check['tmx_format'] == 'normal') {
$content = TMX::create($strings, $locale, 'en-US');
$target_file = 'mozilla_en-US_' . $locale . '.tmx';
} else {
$content = TMX::createOmegat($strings, $locale, 'en-US');
$target_file = 'mozilla_en-US_' . $locale . '_forOmegaT.tmx';
}

$target_file_path = WEB_ROOT . 'download/' . $target_file;
$tmx_id = md5($requested_repositories);
$target_file_name = "mozilla_en-US_{$locale}_{$tmx_id}_{$check['tmx_format']}.tmx";
$target_file_path = WEB_ROOT . "download/{$target_file_name}";

unset($strings);

Expand Down
2 changes: 1 addition & 1 deletion app/views/tmx_downloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span id="download">
<?php
if (!$empty_TMX) {
echo '<a class="button" href="/download/' . $target_file . '">Download</a> or ';
echo '<a class="button" href="/download/' . $target_file_name . '">Download</a> or ';
}
?>
<a href="/downloads">Go back to TMX creation page</a>
Expand Down

0 comments on commit 816fd1c

Please sign in to comment.