mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 01:15:38 -04:00
[machineid] Refactor workers, demand absolute paths
This commit is contained in:
parent
12107b3113
commit
9e359c98a9
1 changed files with 19 additions and 1 deletions
|
@ -29,16 +29,34 @@
|
|||
namespace MachineId
|
||||
{
|
||||
|
||||
static inline bool
|
||||
isAbsolutePath( const QString& fileName )
|
||||
{
|
||||
return fileName.startsWith( '/' );
|
||||
}
|
||||
|
||||
// might need to use a helper to remove the file
|
||||
void
|
||||
removeFile( const QString& rootMountPoint, const QString& fileName )
|
||||
{
|
||||
QFile::remove( rootMountPoint + fileName );
|
||||
if ( isAbsolutePath( fileName ) )
|
||||
{
|
||||
QFile::remove( rootMountPoint + fileName );
|
||||
}
|
||||
// Otherwise, do nothing
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
copyFile( const QString& rootMountPoint, const QString& fileName )
|
||||
{
|
||||
if ( !isAbsolutePath( fileName ) )
|
||||
{
|
||||
return Calamares::JobResult::internalError(
|
||||
QObject::tr( "File not found" ),
|
||||
QObject::tr( "Path <pre>%1</pre> must be an absolute path." ).arg( fileName ),
|
||||
0 );
|
||||
}
|
||||
|
||||
QFile f( fileName );
|
||||
if ( !f.exists() )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue