Posted by hass on September 26, 2009 at 9:42am
2 followers
Jump to:
| Project: | Localization server |
| Version: | 6.x-3.x-dev |
| Component: | l10n_localpacks |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
In "admin/l10n_server/projects/releases/myproject" all download links are broken. They point to http://example.com/myproject-6.x-1.0.tar.gz, but this file does not exists and gives a 404 if clicked.
Comments
#1
Well, what connector module are you using. The download links are expected to be set for some reason and used this way for the table:
<?php'download_link' => array(
'#value' => l(basename($release->download_link), $release->download_link),
),
?>
#2
This are my active Localization server modules:
1. Localization community
2. Localization community for local packages (is this the "connector"?)
3. Localization groups
#3
Hm, it could happen that the local package connector does not set the download link properly...
What it does looks like this:
<?php
// .....
// Packages are always .tar.gz files.
$files = file_scan_directory($workdir, '.tar.gz$');
if (count($files)) {
foreach ($files as $path => $file) {
if (!l10n_community_is_supported_version($path)) {
// Skip files for unsupported versions.
continue;
}
// Get rid of $workdir prefix on file names, eg.
// files/Drupal/drupal-4.6.7.tar.gz or
// files/Ubercart/ubercart-5.x-1.0-alpha8.tar.gz.
$path = $package = trim(preg_replace('!(^'. preg_quote($workdir, '!') .')(.+)\.tar\.gz!', '\2', $path), '/');
$project_title = '';
if (strpos($path, '/')) {
// We have a slash, so this package is in a subfolder.
// Eg. Drupal/drupal-4.6.7 or Ubercart/ubercart-5.x-1.0-alpha8.
// Grab the directory name as project title.
list($project_title, $package) = explode('/', $path);
}
if (strpos($package, '-')) {
// Only remaining are the project uri and release,
// eg. drupal-4.6.7 or ubercart-5.x-1.0-alpha8.
list($project_uri, $release_version) = explode('-', $package, 2);
l10n_localpacks_save_data($project_uri, ($project_title ? $project_title : $project_uri), $release_version, $path .'.tar.gz', filemtime($file->filename));
}
}
}
// .....
function l10n_localpacks_save_data($project_uri, $project_title, $release_version, $filepath, $filedate) {
// .............
db_query("INSERT INTO {l10n_community_release} (pid, title, download_link, file_date, last_parsed) VALUES (%d, '%s', '%s', %d, 0)", $project->pid, $release_version, $filepath, $filedate);
}
?>
So looks like by the time the path gets to the function, it is already shortened. Bad.
#4
I believe I do not fully understand this in a few minutes without adding some krumo()'s... :-)
Should I manually prepend the "Local packages directory" to all filenames in "l10n_community_release.download_link" to fix for broken links? My value is "sites/default/files/project" if you need to know...
#5
Aside - shouldn't the l10n_community_release.file_hash not better set? Maybe I'm currently not syncing, but for the reason that there is no UPDATE anywhere in the module it may cause issues... not sure. I'm guessing here, but see a potential issue for the reason that there is only an INSERT in l10n_project.sync.inc and someone may have started with local packages and than start syncing with d.o later... not sure if this may work.
#6
Currently, migrating a project from one connector to another one does not work (there is no such feature to be more correct). You are right that the localpacks connector does not set a hash value, that might still be useful (at least consistent).
On the download URL, you are right, it should set the full file path with the file name as the download URL, as it is still at the start of the foreach statement. The $path is modified inbetween, and that is the problem IMHO.
#7
Retitling. Would be a nice little fix.
#8
Also, this might be highly related to #550172: No download link stored for some projects.
#9
Still broken for every new release. This is not an edge case - it happens always.