Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file downloader algo duplicating file's extension #60543

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmfiledownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ QVariantMap QgsFileDownloaderAlgorithm::processAlgorithm( const QVariantMap &par
url = downloadedUrl.toDisplayString();
feedback->pushInfo( QObject::tr( "Successfully downloaded %1" ).arg( url ) );

if ( outputFile.startsWith( QgsProcessingUtils::tempFolder( &context ) ) )
if ( parameters.value( QStringLiteral( "OUTPUT" ) ) == QgsProcessing::TEMPORARY_OUTPUT )
{
// the output is temporary and its file name automatically generated, try to add a file extension
const int length = url.size();
Expand Down
8 changes: 8 additions & 0 deletions tests/src/analysis/testqgsprocessingalgspt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,14 @@ void TestQgsProcessingAlgsPt2::fileDownloader()
QVERIFY( ok );
// verify that temporary outputs have the URL file extension appended
QVERIFY( results.value( QStringLiteral( "OUTPUT" ) ).toString().endsWith( QLatin1String( ".txt" ) ) );

const QString outputFileName = QgsProcessingUtils::generateTempFilename( QStringLiteral( "qgis_version.txt" ), &context );
parameters.insert( QStringLiteral( "OUTPUT" ), outputFileName );

results = alg->run( parameters, *context, &feedback, &ok );
QVERIFY( ok );
// compare result filename is the same as provided
QCOMPARE( outputFileName, results.value( QStringLiteral( "OUTPUT" ) ).toString() );
}

void TestQgsProcessingAlgsPt2::rasterize()
Expand Down