diff --git a/3rd-party/Dokan Library-1.0.2/dokan1.dll b/3rd-party/Dokan Library-1.0.2/dokan1.dll index a779e64..a46f6d4 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/dokan1.pdb b/3rd-party/Dokan Library-1.0.2/dokan1.pdb index 2b6d2ef..45ff319 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokan1.pdb and b/3rd-party/Dokan Library-1.0.2/dokan1.pdb differ diff --git a/3rd-party/Dokan Library-1.0.2/dokanctl.exe b/3rd-party/Dokan Library-1.0.2/dokanctl.exe index 8510f92..6e354c6 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokanctl.exe and b/3rd-party/Dokan Library-1.0.2/dokanctl.exe differ diff --git a/3rd-party/Dokan Library-1.0.2/dokanfuse1.dll b/3rd-party/Dokan Library-1.0.2/dokanfuse1.dll index c2bc9f3..4d83878 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokanfuse1.dll and b/3rd-party/Dokan Library-1.0.2/dokanfuse1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/dokannp1.dll b/3rd-party/Dokan Library-1.0.2/dokannp1.dll index 9661427..a7bcbf5 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokannp1.dll and b/3rd-party/Dokan Library-1.0.2/dokannp1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/dokannp1.pdb b/3rd-party/Dokan Library-1.0.2/dokannp1.pdb index 10c228b..df91823 100644 Binary files a/3rd-party/Dokan Library-1.0.2/dokannp1.pdb and b/3rd-party/Dokan Library-1.0.2/dokannp1.pdb differ diff --git a/3rd-party/Dokan Library-1.0.2/driver/dokan1.cat b/3rd-party/Dokan Library-1.0.2/driver/dokan1.cat index 34a3c03..efd80c7 100644 Binary files a/3rd-party/Dokan Library-1.0.2/driver/dokan1.cat and b/3rd-party/Dokan Library-1.0.2/driver/dokan1.cat differ diff --git a/3rd-party/Dokan Library-1.0.2/driver/dokan1.sys b/3rd-party/Dokan Library-1.0.2/driver/dokan1.sys index 93bd1de..e62ff55 100644 Binary files a/3rd-party/Dokan Library-1.0.2/driver/dokan1.sys and b/3rd-party/Dokan Library-1.0.2/driver/dokan1.sys differ diff --git a/3rd-party/Dokan Library-1.0.2/include/dokan/dokan.h b/3rd-party/Dokan Library-1.0.2/include/dokan/dokan.h index cf365cb..a2ac76f 100644 --- a/3rd-party/Dokan Library-1.0.2/include/dokan/dokan.h +++ b/3rd-party/Dokan Library-1.0.2/include/dokan/dokan.h @@ -23,7 +23,7 @@ with this program. If not, see . #define DOKAN_H_ /** Do not include NTSTATUS. Fix duplicate preprocessor definitions */ -#define WIN32_NO_STATUS +#define WIN32_NO_STATUS #include #undef WIN32_NO_STATUS #include diff --git a/3rd-party/Dokan Library-1.0.2/lib/dokan1.lib b/3rd-party/Dokan Library-1.0.2/lib/dokan1.lib index 2a2b3cd..dc94969 100644 Binary files a/3rd-party/Dokan Library-1.0.2/lib/dokan1.lib and b/3rd-party/Dokan Library-1.0.2/lib/dokan1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/lib/dokanfuse1.lib b/3rd-party/Dokan Library-1.0.2/lib/dokanfuse1.lib index 6c1a7b1..558a79c 100644 Binary files a/3rd-party/Dokan Library-1.0.2/lib/dokanfuse1.lib and b/3rd-party/Dokan Library-1.0.2/lib/dokanfuse1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/lib/dokannp1.lib b/3rd-party/Dokan Library-1.0.2/lib/dokannp1.lib index d3c6202..166ce1e 100644 Binary files a/3rd-party/Dokan Library-1.0.2/lib/dokannp1.lib and b/3rd-party/Dokan Library-1.0.2/lib/dokannp1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/sample/fuse_mirror/dokan1.dll b/3rd-party/Dokan Library-1.0.2/sample/fuse_mirror/dokan1.dll index a779e64..a46f6d4 100644 Binary files a/3rd-party/Dokan Library-1.0.2/sample/fuse_mirror/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/sample/fuse_mirror/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan1.dll b/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan1.dll index a779e64..a46f6d4 100644 Binary files a/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan_mirror.sln b/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan_mirror.sln new file mode 100644 index 0000000..14c37b3 --- /dev/null +++ b/3rd-party/Dokan Library-1.0.2/sample/mirror/dokan_mirror.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dokan_mirror", "dokan_mirror.vcxproj", "{DADCBCAD-4429-422E-9FA9-D8E538D0EF94}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Debug|x64.ActiveCfg = Debug|x64 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Debug|x64.Build.0 = Debug|x64 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Debug|x86.ActiveCfg = Debug|Win32 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Debug|x86.Build.0 = Debug|Win32 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Release|x64.ActiveCfg = Release|x64 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Release|x64.Build.0 = Release|x64 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Release|x86.ActiveCfg = Release|Win32 + {DADCBCAD-4429-422E-9FA9-D8E538D0EF94}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/3rd-party/Dokan Library-1.0.2/sample/mirror/mirror.exe b/3rd-party/Dokan Library-1.0.2/sample/mirror/mirror.exe index 9330e94..df8059e 100644 Binary files a/3rd-party/Dokan Library-1.0.2/sample/mirror/mirror.exe and b/3rd-party/Dokan Library-1.0.2/sample/mirror/mirror.exe differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokan1.dll b/3rd-party/Dokan Library-1.0.2/x86/dokan1.dll index c7ce2d5..36d4e34 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/x86/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokan1.pdb b/3rd-party/Dokan Library-1.0.2/x86/dokan1.pdb index 8ff968a..e75995c 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokan1.pdb and b/3rd-party/Dokan Library-1.0.2/x86/dokan1.pdb differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokanctl.exe b/3rd-party/Dokan Library-1.0.2/x86/dokanctl.exe index 0ee0bce..6d49fc4 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokanctl.exe and b/3rd-party/Dokan Library-1.0.2/x86/dokanctl.exe differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokanfuse1.dll b/3rd-party/Dokan Library-1.0.2/x86/dokanfuse1.dll index a47ba0b..3f21cb1 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokanfuse1.dll and b/3rd-party/Dokan Library-1.0.2/x86/dokanfuse1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokannp1.dll b/3rd-party/Dokan Library-1.0.2/x86/dokannp1.dll index f98d442..ad50d93 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokannp1.dll and b/3rd-party/Dokan Library-1.0.2/x86/dokannp1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/dokannp1.pdb b/3rd-party/Dokan Library-1.0.2/x86/dokannp1.pdb index 90342a0..6e922b2 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/dokannp1.pdb and b/3rd-party/Dokan Library-1.0.2/x86/dokannp1.pdb differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/lib/dokan1.lib b/3rd-party/Dokan Library-1.0.2/x86/lib/dokan1.lib index 3e0e341..cdd9f35 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/lib/dokan1.lib and b/3rd-party/Dokan Library-1.0.2/x86/lib/dokan1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/lib/dokanfuse1.lib b/3rd-party/Dokan Library-1.0.2/x86/lib/dokanfuse1.lib index 060621b..1a97507 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/lib/dokanfuse1.lib and b/3rd-party/Dokan Library-1.0.2/x86/lib/dokanfuse1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/lib/dokannp1.lib b/3rd-party/Dokan Library-1.0.2/x86/lib/dokannp1.lib index b5ff0ed..cf3ef5e 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/lib/dokannp1.lib and b/3rd-party/Dokan Library-1.0.2/x86/lib/dokannp1.lib differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/sample/fuse_mirror/dokan1.dll b/3rd-party/Dokan Library-1.0.2/x86/sample/fuse_mirror/dokan1.dll index c7ce2d5..36d4e34 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/sample/fuse_mirror/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/x86/sample/fuse_mirror/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/dokan1.dll b/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/dokan1.dll index c7ce2d5..36d4e34 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/dokan1.dll and b/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/dokan1.dll differ diff --git a/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/mirror.exe b/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/mirror.exe index 727d6cf..7e01474 100644 Binary files a/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/mirror.exe and b/3rd-party/Dokan Library-1.0.2/x86/sample/mirror/mirror.exe differ diff --git a/SiaDrive.Api/AutoThread.cpp b/SiaDrive.Api/AutoThread.cpp index c729d84..2987121 100644 --- a/SiaDrive.Api/AutoThread.cpp +++ b/SiaDrive.Api/AutoThread.cpp @@ -9,7 +9,7 @@ CAutoThread::CAutoThread(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfi } CAutoThread::CAutoThread(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig, std::function autoThreadCallback) : - _siaCurl(siaCurl.GetHostConfig()), + _siaCurl(siaCurl), _siaDriveConfig(siaDriveConfig), _stopEvent(::CreateEvent(nullptr, FALSE, FALSE, nullptr)), _AutoThreadCallback(autoThreadCallback) diff --git a/SiaDrive.Api/SiaApi.cpp b/SiaDrive.Api/SiaApi.cpp index cea3961..ca48d52 100644 --- a/SiaDrive.Api/SiaApi.cpp +++ b/SiaDrive.Api/SiaApi.cpp @@ -34,6 +34,10 @@ String CSiaApi::FormatToSiaPath(String path) path = path.substr(1); } } + else + { + path = L"/"; + } return path; diff --git a/SiaDrive.Api/SiaCurl.cpp b/SiaDrive.Api/SiaCurl.cpp index 56bea0e..ebe5f70 100644 --- a/SiaDrive.Api/SiaCurl.cpp +++ b/SiaDrive.Api/SiaCurl.cpp @@ -3,21 +3,18 @@ #include using namespace Sia::Api; -CSiaCurl::CSiaCurl() : - _curlHandle(curl_easy_init()) +CSiaCurl::CSiaCurl() { SetHostConfig({ L"localhost", 9980, L""}); } -CSiaCurl::CSiaCurl(const SiaHostConfig& hostConfig) : - _curlHandle(curl_easy_init()) +CSiaCurl::CSiaCurl(const SiaHostConfig& hostConfig) { SetHostConfig(hostConfig); } CSiaCurl::~CSiaCurl() { - curl_easy_cleanup(_curlHandle); } SiaCurlError CSiaCurl::CheckApiError(const json& result) @@ -88,24 +85,27 @@ SiaCurlError CSiaCurl::ProcessResponse(const int& res, const int& httpCode, cons SiaCurlError CSiaCurl::_Get(const String& path, json& response) const { - curl_easy_reset(_curlHandle); + CURL* curlHandle = curl_easy_init(); + curl_easy_reset(curlHandle); - curl_easy_setopt(_curlHandle, CURLOPT_USERAGENT, "Sia-Agent"); - curl_easy_setopt(_curlHandle, CURLOPT_URL, ConstructPath(path).c_str()); - curl_easy_setopt(_curlHandle, CURLOPT_WRITEFUNCTION, static_cast([](char *buffer, size_t size, size_t nitems, void *outstream) -> size_t + curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "Sia-Agent"); + curl_easy_setopt(curlHandle, CURLOPT_URL, ConstructPath(path).c_str()); + curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, static_cast([](char *buffer, size_t size, size_t nitems, void *outstream) -> size_t { (*reinterpret_cast(outstream)) += std::string(reinterpret_cast(buffer), size * nitems); return size * nitems; })); std::string result; - curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result); - const CURLcode res = curl_easy_perform(_curlHandle); + curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &result); + const CURLcode res = curl_easy_perform(curlHandle); long httpCode = 0; - curl_easy_getinfo(_curlHandle, CURLINFO_RESPONSE_CODE, &httpCode); + curl_easy_getinfo(curlHandle, CURLINFO_RESPONSE_CODE, &httpCode); - return ProcessResponse(res, httpCode, result, response); + SiaCurlError ret = ProcessResponse(res, httpCode, result, response); + curl_easy_cleanup(curlHandle); + return ret; } bool CSiaCurl::CheckVersion(SiaCurlError& error) const @@ -151,11 +151,12 @@ SiaCurlError CSiaCurl::Post(const String& path, const PostParameters& parameters SiaCurlError ret; if (CheckVersion(ret)) { - curl_easy_reset(_curlHandle); + CURL* curlHandle = curl_easy_init(); + curl_easy_reset(curlHandle); - curl_easy_setopt(_curlHandle, CURLOPT_USERAGENT, "Sia-Agent"); - curl_easy_setopt(_curlHandle, CURLOPT_URL, ConstructPath(path).c_str()); - curl_easy_setopt(_curlHandle, CURLOPT_WRITEFUNCTION, static_cast([](char *buffer, size_t size, size_t nitems, void *outstream) -> size_t + curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "Sia-Agent"); + curl_easy_setopt(curlHandle, CURLOPT_URL, ConstructPath(path).c_str()); + curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, static_cast([](char *buffer, size_t size, size_t nitems, void *outstream) -> size_t { (*reinterpret_cast(outstream)) += std::string(reinterpret_cast(buffer), size * nitems); return size * nitems; @@ -171,16 +172,17 @@ SiaCurlError CSiaCurl::Post(const String& path, const PostParameters& parameters fields += (std::string(CW2A(param.first.c_str())) + "=" + std::string(CW2A(param.second.c_str()))); } - curl_easy_setopt(_curlHandle, CURLOPT_POSTFIELDS, fields.c_str()); + curl_easy_setopt(curlHandle, CURLOPT_POSTFIELDS, fields.c_str()); std::string result; - curl_easy_setopt(_curlHandle, CURLOPT_WRITEDATA, &result); - const CURLcode res = curl_easy_perform(_curlHandle); + curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &result); + const CURLcode res = curl_easy_perform(curlHandle); long httpCode = 0; - curl_easy_getinfo(_curlHandle, CURLINFO_RESPONSE_CODE, &httpCode); + curl_easy_getinfo(curlHandle, CURLINFO_RESPONSE_CODE, &httpCode); ret = ProcessResponse(res, httpCode, result, response); + curl_easy_cleanup(curlHandle); } return ret; diff --git a/SiaDrive.Api/SiaCurl.h b/SiaDrive.Api/SiaCurl.h index a89537a..469150b 100644 --- a/SiaDrive.Api/SiaCurl.h +++ b/SiaDrive.Api/SiaCurl.h @@ -29,8 +29,6 @@ public: ~CSiaCurl(); private: - LPVOID _curlHandle; - Property(SiaHostConfig, HostConfig, public, public) private: diff --git a/SiaDrive.Dokan.Api/SiaDokanDrive.cpp b/SiaDrive.Dokan.Api/SiaDokanDrive.cpp index f1bab00..d3758b4 100644 --- a/SiaDrive.Dokan.Api/SiaDokanDrive.cpp +++ b/SiaDrive.Dokan.Api/SiaDokanDrive.cpp @@ -317,7 +317,25 @@ private: } else // Folder Operation (cache operation only) { - ret = STATUS_NOT_IMPLEMENTED; + String cacheFilePath; + cacheFilePath.resize(MAX_PATH + 1); + if (String(L"\\") == FileName) + { + cacheFilePath = GetCacheLocation(); + } + else + { + PathCombine(&cacheFilePath[0], GetCacheLocation().c_str(), FileName); + } + HANDLE handle = ::CreateFile(cacheFilePath.c_str(), genericDesiredAccess, ShareAccess, &securityAttrib, creationDisposition, fileAttributesAndFlags | FILE_FLAG_BACKUP_SEMANTICS, nullptr); + if (handle == INVALID_HANDLE_VALUE) + { + ret = DokanNtStatusFromWin32(GetLastError()); + } + else + { + DokanFileInfo->Context = reinterpret_cast(handle); // save the file handle in Context + } } } @@ -392,6 +410,28 @@ private: return STATUS_SUCCESS; } + static NTSTATUS DOKAN_CALLBACK Sia_GetVolumeInformation( + LPWSTR VolumeNameBuffer, DWORD VolumeNameSize, LPDWORD VolumeSerialNumber, + LPDWORD MaximumComponentLength, LPDWORD FileSystemFlags, + LPWSTR FileSystemNameBuffer, DWORD FileSystemNameSize, + PDOKAN_FILE_INFO DokanFileInfo) { + UNREFERENCED_PARAMETER(DokanFileInfo); + + wcscpy_s(VolumeNameBuffer, VolumeNameSize, L"SIA"); + *VolumeSerialNumber = 0x19831116; + *MaximumComponentLength = 256; + *FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | + FILE_SUPPORTS_REMOTE_STORAGE | FILE_UNICODE_ON_DISK | + FILE_PERSISTENT_ACLS; + + // File system name could be anything up to 10 characters. + // But Windows check few feature availability based on file system name. + // For this, it is recommended to set NTFS or FAT here. + wcscpy_s(FileSystemNameBuffer, FileSystemNameSize, L"FAT"); + + return STATUS_SUCCESS; + } + public: static void Initialize(CSiaApi* siaApi, CSiaDriveConfig* siaDriveConfig) { @@ -410,7 +450,7 @@ public: _dokanOps.GetDiskFreeSpaceW = nullptr; _dokanOps.GetFileInformation = nullptr; _dokanOps.GetFileSecurityW = nullptr; - _dokanOps.GetVolumeInformationW = nullptr; + _dokanOps.GetVolumeInformationW = Sia_GetVolumeInformation; _dokanOps.LockFile = nullptr; _dokanOps.Mounted = Sia_Mounted; _dokanOps.MoveFileW = nullptr; @@ -428,7 +468,7 @@ public: ZeroMemory(&_dokanOptions, sizeof(DOKAN_OPTIONS)); _dokanOptions.Version = DOKAN_VERSION; _dokanOptions.ThreadCount = 0; // use default - _dokanOptions.Options |= DOKAN_OPTION_CURRENT_SESSION; + _dokanOptions.Options = DOKAN_OPTION_DEBUG; } static void Mount(const wchar_t& driveLetter, const String& cacheLocation) @@ -436,7 +476,7 @@ public: if (_siaApi && !_mountThread) { _cacheLocation = cacheLocation; - wchar_t tmp[] = { driveLetter, ':', 0 }; + wchar_t tmp[] = { driveLetter, ':', '\\', 0 }; _mountPoint = tmp; _mountThread.reset(new std::thread([&]() { @@ -452,6 +492,7 @@ public: if (_mountThread) { DokanRemoveMountPoint(_mountPoint.c_str()); + _mountThread->join(); _mountThread.reset(nullptr); _mountPoint.clear(); @@ -460,6 +501,7 @@ public: static void Shutdown() { + StopFileListThread(); Unmount(); _uploadManager.reset(nullptr); _siaApi = nullptr; @@ -511,7 +553,6 @@ CSiaDokanDrive::CSiaDokanDrive(CSiaApi& siaApi, CSiaDriveConfig* siaDriveConfig) CSiaDokanDrive::~CSiaDokanDrive() { std::lock_guard l(DokanImpl::GetMutex()); - Unmount(); DokanImpl::Shutdown(); } diff --git a/SiaDrive/SiaDrive.vcxproj b/SiaDrive/SiaDrive.vcxproj index 7961662..d2bf999 100644 --- a/SiaDrive/SiaDrive.vcxproj +++ b/SiaDrive/SiaDrive.vcxproj @@ -121,6 +121,7 @@ Windows + RequireAdministrator false @@ -177,6 +178,7 @@ Windows true true + RequireAdministrator false diff --git a/SiaDrive/SiaDriveDlg.cpp b/SiaDrive/SiaDriveDlg.cpp index bb2e44f..c452277 100644 --- a/SiaDrive/SiaDriveDlg.cpp +++ b/SiaDrive/SiaDriveDlg.cpp @@ -108,6 +108,13 @@ CSiaDriveDlg::CSiaDriveDlg(CWnd* pParent /*=NULL*/) m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } +CSiaDriveDlg::~CSiaDriveDlg() +{ + _dokan.reset(nullptr); + _siaApi.reset(nullptr); +} + + void CSiaDriveDlg::DoDataExchange(CDataExchange* pDX) { CDHtmlDialog::DoDataExchange(pDX); @@ -207,21 +214,22 @@ HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/) return S_OK; } -std::unique_ptr d; void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR) { KillTimer(IDT_UPDATE); KillTimer(IDT_UI_ACTION_QUEUE); // Create new API to clear all cached data used by threaded implementations - _siaApi.reset(new CSiaApi({ L"localhost", 9980, L"1.1.1" }, &_siaConfig)); - + if (!_siaApi) + { + _siaApi.reset(new CSiaApi({ L"localhost", 9980, L"1.1.1" }, &_siaConfig)); + } ClearDisplay(); CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr); - if (!d) + if (!_dokan) { - d.reset(new Dokan::CSiaDokanDrive(*_siaApi, &_siaConfig)); - d->Mount('A', CA2W(_siaConfig.GetCacheFolder().c_str()).m_psz, 10); + _dokan.reset(new Dokan::CSiaDokanDrive(*_siaApi, &_siaConfig)); + _dokan->Mount('Y', CA2W(_siaConfig.GetCacheFolder().c_str()).m_psz, 10); } SetTimer(IDT_UPDATE, 2000, nullptr); diff --git a/SiaDrive/SiaDriveDlg.h b/SiaDrive/SiaDriveDlg.h index d4c5046..c40500b 100644 --- a/SiaDrive/SiaDriveDlg.h +++ b/SiaDrive/SiaDriveDlg.h @@ -6,6 +6,7 @@ #include #include "SiaDriveConfig.h" #include "ntray.h" +#include "../SiaDrive.Dokan.Api/SiaDokanDrive.h" using namespace Sia::Api; @@ -16,6 +17,9 @@ class CSiaDriveDlg : public CDHtmlDialog public: CSiaDriveDlg(CWnd* pParent = NULL); // standard constructor +public: + virtual ~CSiaDriveDlg(); + // Dialog Data #ifdef AFX_DESIGN_TIME enum { IDD = IDD_SIADRIVE_DIALOG, IDH = IDR_HTML_SIADRIVE_DIALOG }; @@ -99,6 +103,7 @@ private: CSiaDriveConfig _siaConfig; CTrayNotifyIcon _tray; std::unique_ptr _siaApi; + std::unique_ptr _dokan; CString _walletCreatedSeed; String _receiveAddress; std::mutex _uiActionQueueMutex;