mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
SixCycle - Support Compressed Download
.. where file name is e.g. tcx_*.gz to indicate a TCX file using gzip compression.
This commit is contained in:
@@ -234,7 +234,11 @@ CloudService::uncompressRide(QByteArray *data, QString name, QStringList &errors
|
||||
|
||||
QByteArray jsonData;
|
||||
|
||||
if (downloadCompression == zip) {
|
||||
// some services will offer file as compressed or uncompressed
|
||||
// data. In which case they must add .zip or .gz to the end of the
|
||||
// filename to indicate it. The file format must still be included
|
||||
// in the name e.g. .pwx.gz or .fit.zip
|
||||
if (name.endsWith(".zip")) {
|
||||
// write out to a zip file first
|
||||
QTemporaryFile zipfile;
|
||||
zipfile.open();
|
||||
@@ -247,7 +251,7 @@ CloudService::uncompressRide(QByteArray *data, QString name, QStringList &errors
|
||||
jsonData = reader.fileData(info.filePath);
|
||||
// name without the .zip
|
||||
name = name.mid(0, name.length()-4);
|
||||
} else if (downloadCompression == gzip) {
|
||||
} else if (name.endsWith(".gz")) {
|
||||
jsonData = gUncompress(*data);
|
||||
// name without the .gz
|
||||
name = name.mid(0, name.length()-3);
|
||||
@@ -255,7 +259,7 @@ CloudService::uncompressRide(QByteArray *data, QString name, QStringList &errors
|
||||
jsonData = *data;
|
||||
}
|
||||
|
||||
// uncompress and write to tmp
|
||||
// uncompress and write to tmp preserviing the file extension
|
||||
QString tmp = context->athlete->home->temp().absolutePath() + "/" + QFileInfo(name).baseName() + "." + QFileInfo(name).suffix();
|
||||
|
||||
// uncompress and write a file
|
||||
|
||||
@@ -279,6 +279,16 @@ SixCycle::readdir(QString path, QStringList &errors, QDateTime from, QDateTime t
|
||||
//add->name = name;
|
||||
QString dateString = each["activityStartDateTime"].toString();
|
||||
QString suffix = QFileInfo(add->id).suffix();
|
||||
|
||||
// data might be compressed remotely, need to adapt to their scheme of naming
|
||||
// the rawfiles with the format at the front and compression at the back of the
|
||||
// filename; e.g:
|
||||
// https://s3.amazonaws.com/sixcycle/rawFiles/tcx_ba4319c2-a6dd-4503-9a50-0cb1f0f832ab.gz
|
||||
//
|
||||
if (suffix == "gz") {
|
||||
QString prefix = add->id.split("/").last().split("_").first();
|
||||
suffix = prefix + "." + suffix;
|
||||
}
|
||||
QDateTime startTime= QDateTime::fromString(dateString, Qt::ISODate).toLocalTime();
|
||||
QChar zero = QLatin1Char ( '0' );
|
||||
add->name = QString ( "%1_%2_%3_%4_%5_%6.%7" )
|
||||
@@ -463,8 +473,8 @@ SixCycle::readFileCompleted()
|
||||
|
||||
printd("reply begins:%s", buffers.value(reply)->toStdString().substr(0,80).c_str());
|
||||
|
||||
// lets not override the date use an unformatted file name
|
||||
QString name = QString("temp.%1").arg(QFileInfo(replyName(reply)).suffix());
|
||||
// lets not override the date use an unformatted file name, keeping any .tcx.gz style suffix
|
||||
QString name = QString("temp.%1").arg(QFileInfo(replyName(reply)).completeSuffix());
|
||||
|
||||
// process it then ........
|
||||
notifyReadComplete(buffers.value(reply), name, tr("Completed."));
|
||||
|
||||
Reference in New Issue
Block a user