@@ -400,26 +400,41 @@ void PluginManager::installFromUrl( const QString &url )
400
400
file.write ( data );
401
401
file.close ();
402
402
403
+ bool pluginDirectoryWithinZip = false ;
404
+ QString pluginDirectoryName;
403
405
QStringList zipFiles = QgsZipUtils::files ( filePath );
404
- if ( zipFiles.contains ( QStringLiteral ( " main.qml" ) ) )
406
+ if ( zipFiles.at ( 0 ).indexOf ( ' /' ) >= 0 )
407
+ {
408
+ pluginDirectoryName = zipFiles.at ( 0 ).mid ( 0 , zipFiles.at ( 0 ).indexOf ( ' /' ) );
409
+ pluginDirectoryWithinZip = true ;
410
+ }
411
+ if ( zipFiles.contains ( QStringLiteral ( " %1main.qml" ).arg ( !pluginDirectoryName.isEmpty () ? pluginDirectoryName + " /" : QString () ) ) )
405
412
{
406
413
// Insure no previous version is running
407
414
disableAppPlugin ( fileInfo.completeBaseName () );
408
415
409
416
// Remove the .zip suffix as well as version information (e.g. myplugin-v1.0.zip becomes myplugin)
410
- const QString pluginDirectoryName = fileName.replace ( QRegularExpression ( " (-v?\\ d+(\\ .\\ d+)*)?.zIP$" , QRegularExpression::CaseInsensitiveOption ), QString () );
417
+ if ( !pluginDirectoryWithinZip )
418
+ {
419
+ pluginDirectoryName = fileName.replace ( QRegularExpression ( " (-v?\\ d+(\\ .\\ d+)*)?.zIP$" , QRegularExpression::CaseInsensitiveOption ), QString () );
420
+ }
421
+
411
422
QDir pluginDirectory = QStringLiteral ( " %1/plugins/%2" ).arg ( dataDir, pluginDirectoryName );
412
423
if ( pluginDirectory.exists () )
413
424
{
414
425
pluginDirectory.removeRecursively ();
415
426
}
416
427
pluginDirectory.mkpath ( " ." );
428
+ if ( pluginDirectoryWithinZip )
429
+ {
430
+ pluginDirectory.cdUp ();
431
+ }
417
432
if ( QgsZipUtils::unzip ( filePath, pluginDirectory.absolutePath (), zipFiles, false ) )
418
433
{
419
434
file.remove ();
420
435
421
436
refreshAppPlugins ();
422
- emit installEnded ( pluginDirectory. dirName () );
437
+ emit installEnded ( pluginDirectoryName );
423
438
424
439
return ;
425
440
}
0 commit comments