1
0
This commit is contained in:
Scott E. Graves
2017-03-28 12:41:17 -05:00
parent 0055169dca
commit ffaf818e5f
7 changed files with 38 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ SString FilePath::FinalizePath(const SString& path)
std::wregex r(L"/+");
SString str = std::regex_replace(path.str(), r, L"\\");
std::wregex r2(L"\\\\+");
return std::regex_replace(str.str(), r2, L"\\\\");
return std::regex_replace(str.str(), r2, L"\\");
#else
a
#endif

View File

@@ -41,7 +41,7 @@ SString GenerateSha256(const SString& str)
HCRYPTHASH hHash = 0;
BOOL ok = ::CryptAcquireContext(&hCryptProv, nullptr, nullptr, PROV_RSA_AES, 0);
ok = ok && ::CryptCreateHash(hCryptProv, CALG_SHA_256, 0, 0, &hHash);
ok = ok && ::CryptHashData(hHash, reinterpret_cast<const BYTE*>(&str[0]), str.ByteLength(), 0);
ok = ok && ::CryptHashData(hHash, reinterpret_cast<const BYTE*>(&str[0]), static_cast<DWORD>(str.ByteLength()), 0);
if (ok)
{
DWORD dwHashLen;

View File

@@ -37,7 +37,7 @@ try\
}\
catch (SQLite::Exception e)\
{\
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));\
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("SetStatus", e)));\
}
template <typename... Ts>
@@ -236,7 +236,7 @@ void CUploadManager::HandleFileRemove(const CSiaCurl& siaCurl, const SString& si
}
catch (SQLite::Exception e)
{
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("HandleFileRemove", e)));
}
}
@@ -362,6 +362,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
// Upload still active, don't process another file
else
{
// TODO Check upload count
processNext = false;
}
}
@@ -375,7 +376,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
catch (const SQLite::Exception& e)
{
// error condition - database not initialized (i.e. no table)?
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("AutoThreadCallback(/renter/files)", e)));
processNext = false;
}
@@ -383,7 +384,6 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
{
try
{
// TODO Rethink this - could hang here for quite a while
std::lock_guard<std::mutex> l(_uploadMutex);
SQLite::Statement query(_uploadDatabase, QUERY_UPLOADS_BY_STATUS);
query.bind("@status", static_cast<unsigned>(UploadStatus::Queued));
@@ -393,6 +393,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
SString siaPath = static_cast<const char*>(query.getColumn(query.getColumnIndex("sia_path")));
SString filePath = static_cast<const char*>(query.getColumn(query.getColumnIndex("file_path")));
SString sdFilePath = static_cast<const char*>(query.getColumn(query.getColumnIndex("sd_file_path")));
// TODO Rethink this - could hang here for quite a while creating temporary files
if (CreateSiaDriveFile(siaPath, filePath, sdFilePath + ".temp", sdFilePath))
{
// TODO Validate response
@@ -408,7 +409,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
catch (const SQLite::Exception& e)
{
// error condition
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("AutoThreadCallback(processNext)", e)));
}
}
}
@@ -476,7 +477,7 @@ UploadError CUploadManager::AddOrUpdate(const SString& siaPath, SString filePath
insert.bind("@status", static_cast<unsigned>(UploadStatus::Queued));
if (insert.exec() == 1)
{
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(UploadAddedToQueue(siaPath, filePath, siaDriveFilePath)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(FileAddedToQueue(siaPath, filePath, siaDriveFilePath)));
}
else
{
@@ -486,14 +487,14 @@ UploadError CUploadManager::AddOrUpdate(const SString& siaPath, SString filePath
}
catch (SQLite::Exception e)
{
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("AddOrUpdate(insert)", e)));
ret = UploadError::DatabaseError;
}
}
}
catch (SQLite::Exception e)
{
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("AddOrUpdate(query)", e)));
ret = UploadError::DatabaseError;
}
}
@@ -553,7 +554,7 @@ UploadError CUploadManager::Remove(const SString& siaPath)
}
catch (SQLite::Exception e)
{
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("Remove", e)));
ret = UploadError::DatabaseError;
}

View File

@@ -416,7 +416,8 @@ private:
}
else
{
cachePath.Append(&fileName[1]);
cachePath.Append(fileName);
findFile.Append(fileName);
if (cachePath.IsDirectory())
{
siaFileQuery += L"/*.*";
@@ -426,11 +427,10 @@ private:
{
siaDirQuery = cachePath;
siaDirQuery = CSiaApi::FormatToSiaPath(siaDirQuery.RemoveFileName());
findFile.Append(fileName);
}
}
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFindFiles(cachePath, siaDirQuery, siaFileQuery)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFindFiles(cachePath, siaDirQuery, siaFileQuery, findFile)));
WIN32_FIND_DATA findData = { 0 };
HANDLE findHandle = ::FindFirstFile(&findFile[0], &findData);
@@ -768,7 +768,7 @@ private:
return STATUS_SUCCESS;
}
if ((static_cast<UINT64>(offset) + bytesToWrite) > li.QuadPart)
if (static_cast<UINT64>(offset + bytesToWrite) > li.QuadPart)
{
UINT64 bytes = li.QuadPart - offset;
if (bytes >> 32)