diff --git a/src/siadrive_dokan_api/siadokandrive.cpp b/src/siadrive_dokan_api/siadokandrive.cpp index 2ee3f38..1e8e0d1 100644 --- a/src/siadrive_dokan_api/siadokandrive.cpp +++ b/src/siadrive_dokan_api/siadokandrive.cpp @@ -848,8 +848,6 @@ public: { _siaApi = siaApi; _siaDriveConfig = siaDriveConfig; - // May spend a little wait time here while files are cleaned-up and re-added to queue - _uploadManager.reset(new CUploadManager(CSiaCurl(siaApi->GetHostConfig()), siaDriveConfig)); _dokanOps.Cleanup = Sia_Cleanup; _dokanOps.CloseFile = Sia_CloseFile; _dokanOps.DeleteDirectory = nullptr; @@ -891,6 +889,8 @@ public: _mountPoint = tmp; _mountThread.reset(new std::thread([&]() { + // May spend a little wait time here while files are cleaned-up and re-added to queue + _uploadManager.reset(new CUploadManager(CSiaCurl(_siaApi->GetHostConfig()), _siaDriveConfig)); _dokanOptions.MountPoint = _mountPoint.ToUpper().str().c_str(); _mountStatus = DokanMain(&_dokanOptions, &_dokanOps); OutputDebugString(std::to_wstring(_mountStatus).c_str()); @@ -902,7 +902,8 @@ public: { if (_mountThread) { - DokanRemoveMountPoint(&_mountPoint[0]); + while (!DokanRemoveMountPoint(&_mountPoint[0])) + ::Sleep(1000); _mountThread->join(); _mountThread.reset(nullptr); _mountPoint = "";