Skip to content

Commit

Permalink
Add query to TLE download filename, to avoid clashes. Fixes f4exb#1647
Browse files Browse the repository at this point in the history
  • Loading branch information
srcejon committed Apr 28, 2023
1 parent 485986a commit 02f264f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugins/feature/satellitetracker/satellitetracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,19 @@ QString SatelliteTracker::tleURLToFilename(const QString& string)
{
if (string == "https://db.satnogs.org/api/tle/")
return satNogsTLEFilename();

// Celestrak now uses the same filename with different queries, so we need to include the query
// in the file name, so the filenames don't clash. E.g:
// https://celestrak.org/NORAD/elements/gp.php?GROUP=gps-ops&FORMAT=tle
// https://celestrak.org/NORAD/elements/gp.php?GROUP=active&FORMAT=tle
QUrl url(string);
return HttpDownloadManager::downloadDir() + "/tle_" + url.fileName();
QString fileName = HttpDownloadManager::downloadDir() + "/tle_" + url.fileName();
if (url.hasQuery())
{
QString query = url.query().replace('%', '_').replace('&', '_').replace('=', '_');
fileName = fileName + query;
}
return fileName;
}

void SatelliteTracker::downloadFinished(const QString& filename, bool success)
Expand Down

0 comments on commit 02f264f

Please sign in to comment.