Fixes
This commit is contained in:
@@ -76,10 +76,31 @@ private:
|
||||
ret = ApiSuccess(_siaApi->GetRenter()->DownloadFile(siaPath, tempFilePath));
|
||||
if (ret)
|
||||
{
|
||||
auto id = dokanFileInfo->Context;
|
||||
::CloseHandle(reinterpret_cast<HANDLE>(id));
|
||||
|
||||
FilePath src(tempFilePath);
|
||||
FilePath dest(GetCacheLocation(), siaPath);
|
||||
ret = src.MoveFile(dest);
|
||||
if (!ret)
|
||||
ret = dest.DeleteFile() && src.MoveFile(dest);
|
||||
if (ret)
|
||||
{
|
||||
HANDLE handle = ::CreateFile(&dest[0], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
|
||||
std::lock_guard<std::mutex> l(_dokanMutex);
|
||||
auto ofi = _openFileMap[id];
|
||||
_openFileMap.erase(id);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ofi.Dummy = false;
|
||||
dokanFileInfo->Context = reinterpret_cast<ULONG64>(handle);
|
||||
_openFileMap.insert({ dokanFileInfo->Context, ofi });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
src.DeleteFile();
|
||||
}
|
||||
@@ -90,7 +111,7 @@ private:
|
||||
|
||||
while (active)
|
||||
{
|
||||
DokanResetTimeout(60000, dokanFileInfo);
|
||||
DokanResetTimeout(30000, dokanFileInfo);
|
||||
::Sleep(10);
|
||||
}
|
||||
|
||||
@@ -387,7 +408,7 @@ private:
|
||||
{
|
||||
isDummy = (siaExists && (FileSize(&cacheFilePath[0]) == 0));
|
||||
}
|
||||
else if (exists)
|
||||
else if (siaExists)
|
||||
{
|
||||
isDummy = AddDummyFileToCache(siaPath);
|
||||
if (!isDummy)
|
||||
@@ -738,8 +759,6 @@ private:
|
||||
LONGLONG offset,
|
||||
PDOKAN_FILE_INFO dokanFileInfo)
|
||||
{
|
||||
// TODO Check dummy and add to cache if not found
|
||||
|
||||
FilePath filePath(GetCacheLocation(), fileName);
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanReadFile(filePath)));
|
||||
|
||||
@@ -747,7 +766,8 @@ private:
|
||||
SString siaPath;
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_fileTreeMutex);
|
||||
isDummy = _openFileMap.find(dokanFileInfo->Context) != _openFileMap.end();
|
||||
auto it = _openFileMap.find(dokanFileInfo->Context);
|
||||
isDummy = ((it != _openFileMap.end()) && it->second.Dummy);
|
||||
if (isDummy)
|
||||
{
|
||||
siaPath = _openFileMap[dokanFileInfo->Context].SiaPath;
|
||||
@@ -756,6 +776,7 @@ private:
|
||||
|
||||
if (isDummy)
|
||||
{
|
||||
// TODO taking too long
|
||||
if (!AddFileToCache(siaPath, dokanFileInfo))
|
||||
{
|
||||
return STATUS_INVALID_DEVICE_STATE;
|
||||
|
Reference in New Issue
Block a user