mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
Adds more explicit error message when auxiliary storage is saved
This commit is contained in:
parent
119cd8ace9
commit
1ecc57d2a2
@ -626,15 +626,33 @@ bool QgsAuxiliaryStorage::duplicateTable( const QgsDataSourceUri &ogrUri, const
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsAuxiliaryStorage::saveAs( const QString &filename ) const
|
QString QgsAuxiliaryStorage::errorString() const
|
||||||
{
|
{
|
||||||
if ( QFile::exists( filename ) )
|
return mErrorString;
|
||||||
QFile::remove( filename );
|
|
||||||
|
|
||||||
return QFile::copy( currentFileName(), filename );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsAuxiliaryStorage::saveAs( const QgsProject &project ) const
|
bool QgsAuxiliaryStorage::saveAs( const QString &filename )
|
||||||
|
{
|
||||||
|
mErrorString.clear();
|
||||||
|
|
||||||
|
QFile dest( filename );
|
||||||
|
if ( dest.exists() && !dest.remove() )
|
||||||
|
{
|
||||||
|
mErrorString = dest.errorString();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile origin( currentFileName() );
|
||||||
|
if ( !origin.copy( filename ) )
|
||||||
|
{
|
||||||
|
mErrorString = origin.errorString();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QgsAuxiliaryStorage::saveAs( const QgsProject &project )
|
||||||
{
|
{
|
||||||
return saveAs( filenameForProject( project ) );
|
return saveAs( filenameForProject( project ) );
|
||||||
}
|
}
|
||||||
|
@ -319,12 +319,14 @@ class CORE_EXPORT QgsAuxiliaryStorage
|
|||||||
*/
|
*/
|
||||||
QString currentFileName() const;
|
QString currentFileName() const;
|
||||||
|
|
||||||
|
QString errorString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current database to a new path.
|
* Saves the current database to a new path.
|
||||||
*
|
*
|
||||||
* \returns true if everything is saved, false otherwise
|
* \returns true if everything is saved, false otherwise
|
||||||
*/
|
*/
|
||||||
bool saveAs( const QString &filename ) const;
|
bool saveAs( const QString &filename );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current database to a new path for a specific project.
|
* Saves the current database to a new path for a specific project.
|
||||||
@ -333,7 +335,7 @@ class CORE_EXPORT QgsAuxiliaryStorage
|
|||||||
*
|
*
|
||||||
* \returns true if everything is saved, false otherwise
|
* \returns true if everything is saved, false otherwise
|
||||||
*/
|
*/
|
||||||
bool saveAs( const QgsProject &project ) const;
|
bool saveAs( const QgsProject &project );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current database.
|
* Saves the current database.
|
||||||
@ -408,6 +410,7 @@ class CORE_EXPORT QgsAuxiliaryStorage
|
|||||||
QString mFileName; // original filename
|
QString mFileName; // original filename
|
||||||
QString mTmpFileName; // temporary filename used in copy mode
|
QString mTmpFileName; // temporary filename used in copy mode
|
||||||
bool mCopy = false;
|
bool mCopy = false;
|
||||||
|
QString mErrorString;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1649,7 +1649,10 @@ bool QgsProject::write()
|
|||||||
|
|
||||||
// errors raised during writing project file are more important
|
// errors raised during writing project file are more important
|
||||||
if ( !asOk && writeOk )
|
if ( !asOk && writeOk )
|
||||||
setError( tr( "Unable to save auxiliary storage" ) );
|
{
|
||||||
|
const QString err = mAuxiliaryStorage->errorString();
|
||||||
|
setError( tr( "Unable to save auxiliary storage ('%1')" ).arg( err ) );
|
||||||
|
}
|
||||||
|
|
||||||
return asOk && writeOk;
|
return asOk && writeOk;
|
||||||
}
|
}
|
||||||
@ -2614,7 +2617,8 @@ bool QgsProject::zip( const QString &filename )
|
|||||||
|
|
||||||
if ( ! saveAuxiliaryStorage( asFileName ) )
|
if ( ! saveAuxiliaryStorage( asFileName ) )
|
||||||
{
|
{
|
||||||
setError( tr( "Unable to save auxiliary storage" ) );
|
const QString err = mAuxiliaryStorage->errorString();
|
||||||
|
setError( tr( "Unable to save auxiliary storage ('%1')" ).arg( err ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user