Skip to content

Commit

Permalink
Merge branch 'rob/6583-ensure-latest-file-download-not-older-cached' …
Browse files Browse the repository at this point in the history
…into rob/release-sprint-2022-11-14-to-2022-11-21-2
  • Loading branch information
Rob Davis committed Jan 9, 2023
2 parents 4e785f6 + d2736fd commit a1b2045
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sites/all/modules/custom/dwcarchiver/dwcarchiver.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ function dwcarchiver_overview_page() {
}
$row[] = l('Preview', 'admin/config/content/dwcarchiver/' . $archive->machine_name . '/preview');
$row[] = l('Rebuild', 'admin/config/content/dwcarchiver/' . $archive->machine_name . '/rebuild');
$row[] = l('Download', $archive->machine_name . '.zip');

// defeat the cache by adding a unique pattern to end, so that the latest archived file is always downloaded
// credit: https://www.drupal.org/forum/support/post-installation/2009-05-09/prevent-question-marks-in-autopath-links-from-being#comment-4305604
// and: https://stackoverflow.com/a/3055584/227926
$timeNow = time();
$row[] = l('Download', $archive->machine_name . '.zip', array('query' => array('timestamp' => $timeNow)));
$rows[] = $row;
}
return [
Expand Down
6 changes: 6 additions & 0 deletions sites/all/modules/custom/dwcarchiver/dwcarchiver.rebuild.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ function dwcarchiver_rebuild($dwcarchiver, $deliver = TRUE) {
drupal_set_message(t('Unable to rebuild the archive, please contact an administrator.'), 'error');
}
else {
// clear file cached for following path
// e.g. https://myriatrix.myspecies.info/gbif-dwca.zip
$host = _varnish_get_host();
$base = base_path();
varnish_purge($host, '^' . $base . '/gbif-dwca.zip*' );

_dwcarchiver_create_xml_and_data_files($dwcarchiver, $zip);
$zip->close();
// Move the zip file to the dwcarchiver folder.
Expand Down

0 comments on commit a1b2045

Please sign in to comment.