Skip to content

Commit

Permalink
Windows: stop storage service during write
Browse files Browse the repository at this point in the history
The moment we write the block containing the partition table
Windows services will start accessing the SD card and write data
to "System volume information" folder.

If others are writing to disk concurrently this may or may not
affect our ability to eject the drive.
Stop StorSvc temporarily between us writing the partition table
(saved for last) and ejecting the SD card, just in case.

Ref #75
  • Loading branch information
maxnet committed Jul 3, 2020
1 parent 19bfc8e commit 5f42c7d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions downloadthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,14 @@ void DownloadThread::_writeComplete()

emit finalizing();

#ifdef Q_OS_WIN
// Temporarily stop storage services to prevent \[System Volume Information]\WPSettings.dat being created
QProcess p1;
QStringList args = {"stop", "StorSvc"};
qDebug() << "Stopping storage services";
p1.execute("net", args);
#endif

if (_firstBlock)
{
qDebug() << "Writing first block (which we skipped at first)";
Expand All @@ -610,6 +618,13 @@ void DownloadThread::_writeComplete()
#endif
eject_disk(_filename.constData());

#ifdef Q_OS_WIN
QStringList args = {"start", "StorSvc"};
QProcess *p2 = new QProcess(this);
qDebug() << "Restarting storage services";
p2->startDetached("net", args);
#endif

emit success();
}

Expand Down

0 comments on commit 5f42c7d

Please sign in to comment.