From 9490d6a7fec349d2fb143d8f97262329b8159626 Mon Sep 17 00:00:00 2001 From: Nicolas Godet <39594821+nicogodet@users.noreply.github.com> Date: Tue, 11 Feb 2025 13:45:13 +0100 Subject: [PATCH 1/4] Prefer check on `QgsProcessing::TEMPORARY_OUTPUT` instead of filepath --- src/analysis/processing/qgsalgorithmfiledownloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analysis/processing/qgsalgorithmfiledownloader.cpp b/src/analysis/processing/qgsalgorithmfiledownloader.cpp index 45432eb92b75..c6adb3c8770a 100644 --- a/src/analysis/processing/qgsalgorithmfiledownloader.cpp +++ b/src/analysis/processing/qgsalgorithmfiledownloader.cpp @@ -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(); From 5a56d7eec6a15968045cb91011576053a4be3b6f Mon Sep 17 00:00:00 2001 From: Nicolas Godet <39594821+nicogodet@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:40:27 +0100 Subject: [PATCH 2/4] Add test --- tests/src/analysis/testqgsprocessingalgspt2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/src/analysis/testqgsprocessingalgspt2.cpp b/tests/src/analysis/testqgsprocessingalgspt2.cpp index b09d6a12df02..d9f7f1549f43 100644 --- a/tests/src/analysis/testqgsprocessingalgspt2.cpp +++ b/tests/src/analysis/testqgsprocessingalgspt2.cpp @@ -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() From f2b7f5443ebedd9416bf65a2e4f9c4e152a82c91 Mon Sep 17 00:00:00 2001 From: Nicolas Godet <39594821+nicogodet@users.noreply.github.com> Date: Wed, 12 Feb 2025 09:25:29 +0100 Subject: [PATCH 3/4] fix compil --- tests/src/analysis/testqgsprocessingalgspt2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/analysis/testqgsprocessingalgspt2.cpp b/tests/src/analysis/testqgsprocessingalgspt2.cpp index d9f7f1549f43..b41c87773543 100644 --- a/tests/src/analysis/testqgsprocessingalgspt2.cpp +++ b/tests/src/analysis/testqgsprocessingalgspt2.cpp @@ -1145,7 +1145,7 @@ void TestQgsProcessingAlgsPt2::fileDownloader() // 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 ); + const QString outputFileName = QgsProcessingUtils::generateTempFilename( QStringLiteral( "qgis_version.txt" ), &context ); parameters.insert( QStringLiteral( "OUTPUT" ), outputFileName ); results = alg->run( parameters, *context, &feedback, &ok ); From d8b7b67b85488a97caa95827acb8f741d82f80da Mon Sep 17 00:00:00 2001 From: Nicolas Godet <39594821+nicogodet@users.noreply.github.com> Date: Wed, 12 Feb 2025 10:04:40 +0100 Subject: [PATCH 4/4] fix --- tests/src/analysis/testqgsprocessingalgspt2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/analysis/testqgsprocessingalgspt2.cpp b/tests/src/analysis/testqgsprocessingalgspt2.cpp index b41c87773543..aac2f8bb0841 100644 --- a/tests/src/analysis/testqgsprocessingalgspt2.cpp +++ b/tests/src/analysis/testqgsprocessingalgspt2.cpp @@ -1145,7 +1145,7 @@ void TestQgsProcessingAlgsPt2::fileDownloader() // 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 ); + const QString outputFileName = QgsProcessingUtils::generateTempFilename( QStringLiteral( "qgis_version.txt" ) ); parameters.insert( QStringLiteral( "OUTPUT" ), outputFileName ); results = alg->run( parameters, *context, &feedback, &ok );