mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Linux: delay extracting .zip after mount on sandboxed systems
This commit is contained in:
parent
f682c3a7dd
commit
c8409d7419
1 changed files with 30 additions and 1 deletions
|
@ -193,6 +193,25 @@ void DownloadExtractThread::extractImageRun()
|
|||
archive_read_free(a);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
/* Returns true if folder lives on a different device than parent directory */
|
||||
inline bool isMountPoint(const QString &folder)
|
||||
{
|
||||
struct stat statFolder, statParent;
|
||||
QFileInfo fi(folder);
|
||||
QByteArray folderAscii = folder.toLatin1();
|
||||
QByteArray parentDir = fi.dir().path().toLatin1();
|
||||
|
||||
if ( ::stat(folderAscii.constData(), &statFolder) == -1
|
||||
|| ::stat(parentDir.constData(), &statParent) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (statFolder.st_dev != statParent.st_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
void DownloadExtractThread::extractMultiFileRun()
|
||||
{
|
||||
QString folder;
|
||||
|
@ -228,7 +247,7 @@ void DownloadExtractThread::extractMultiFileRun()
|
|||
fatpartition += "p1";
|
||||
else
|
||||
fatpartition += "1";
|
||||
args << fatpartition << folder;
|
||||
args << "-t" << "vfat" << fatpartition << folder;
|
||||
|
||||
if (QProcess::execute("mount", args) != 0)
|
||||
{
|
||||
|
@ -238,6 +257,16 @@ void DownloadExtractThread::extractMultiFileRun()
|
|||
td.setAutoRemove(false);
|
||||
manualmount = true;
|
||||
}
|
||||
|
||||
/* When run under some container environments -even when udisks2 said
|
||||
it completed mounting the fs- we may have to wait a bit more
|
||||
until mountpoint is available in sandbox which lags behind */
|
||||
for (int tries=0; tries<3; tries++)
|
||||
{
|
||||
if (isMountPoint(folder))
|
||||
break;
|
||||
QThread::sleep(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (folder.isEmpty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue