mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Allow temporary folder location to be overridden through
QgsProcessingContext
This commit is contained in:
parent
30598b9ad9
commit
fa22256717
@ -585,6 +585,30 @@ Sets the logging ``level`` for algorithms to use when pushing feedback messages
|
||||
.. seealso:: :py:func:`logLevel`
|
||||
|
||||
.. versionadded:: 3.20
|
||||
%End
|
||||
|
||||
QString temporaryFolder() const;
|
||||
%Docstring
|
||||
Returns the (optional) temporary folder to use when running algorithms.
|
||||
|
||||
If set, this overrides the standard global Processing temporary folder and should be used
|
||||
for all temporary files created during algorithm execution.
|
||||
|
||||
.. seealso:: :py:func:`setTemporaryFolder`
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void setTemporaryFolder( const QString &folder );
|
||||
%Docstring
|
||||
Sets the (optional) temporary ``folder`` to use when running algorithms.
|
||||
|
||||
If set, this overrides the standard global Processing temporary folder and should be used
|
||||
for all temporary files created during algorithm execution.
|
||||
|
||||
.. seealso:: :py:func:`temporaryFolder`
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
QVariantMap exportToMap() const;
|
||||
|
@ -147,6 +147,16 @@ void QgsProcessingContext::setLogLevel( LogLevel level )
|
||||
mLogLevel = level;
|
||||
}
|
||||
|
||||
QString QgsProcessingContext::temporaryFolder() const
|
||||
{
|
||||
return mTemporaryFolderOverride;
|
||||
}
|
||||
|
||||
void QgsProcessingContext::setTemporaryFolder( const QString &folder )
|
||||
{
|
||||
mTemporaryFolderOverride = folder;
|
||||
}
|
||||
|
||||
QVariantMap QgsProcessingContext::exportToMap() const
|
||||
{
|
||||
QVariantMap res;
|
||||
|
@ -100,6 +100,7 @@ class CORE_EXPORT QgsProcessingContext
|
||||
mDistanceUnit = other.mDistanceUnit;
|
||||
mAreaUnit = other.mAreaUnit;
|
||||
mLogLevel = other.mLogLevel;
|
||||
mTemporaryFolderOverride = other.mTemporaryFolderOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -657,6 +658,28 @@ class CORE_EXPORT QgsProcessingContext
|
||||
*/
|
||||
void setLogLevel( LogLevel level );
|
||||
|
||||
/**
|
||||
* Returns the (optional) temporary folder to use when running algorithms.
|
||||
*
|
||||
* If set, this overrides the standard global Processing temporary folder and should be used
|
||||
* for all temporary files created during algorithm execution.
|
||||
*
|
||||
* \see setTemporaryFolder()
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
QString temporaryFolder() const;
|
||||
|
||||
/**
|
||||
* Sets the (optional) temporary \a folder to use when running algorithms.
|
||||
*
|
||||
* If set, this overrides the standard global Processing temporary folder and should be used
|
||||
* for all temporary files created during algorithm execution.
|
||||
*
|
||||
* \see temporaryFolder()
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void setTemporaryFolder( const QString &folder );
|
||||
|
||||
/**
|
||||
* Exports the context's settings to a variant map.
|
||||
*
|
||||
@ -713,6 +736,8 @@ class CORE_EXPORT QgsProcessingContext
|
||||
|
||||
LogLevel mLogLevel = DefaultLevel;
|
||||
|
||||
QString mTemporaryFolderOverride;
|
||||
|
||||
#ifdef SIP_RUN
|
||||
QgsProcessingContext( const QgsProcessingContext &other );
|
||||
#endif
|
||||
|
@ -1037,7 +1037,13 @@ QString QgsProcessingUtils::tempFolder( const QgsProcessingContext *context )
|
||||
static QString sFolder;
|
||||
static QMutex sMutex;
|
||||
QMutexLocker locker( &sMutex );
|
||||
const QString basePath = QgsProcessing::settingsTempPath->value();
|
||||
QString basePath;
|
||||
|
||||
if ( context )
|
||||
basePath = context->temporaryFolder();
|
||||
if ( basePath.isEmpty() )
|
||||
basePath = QgsProcessing::settingsTempPath->value();
|
||||
|
||||
if ( basePath.isEmpty() )
|
||||
{
|
||||
// default setting -- automatically create a temp folder
|
||||
|
Loading…
x
Reference in New Issue
Block a user