Upload manager changes
This commit is contained in:
@@ -162,6 +162,7 @@ void CUploadManager::AddOrUpdate(const String& siaPath, const String& filePath)
|
|||||||
query.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
|
query.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
|
||||||
query.bind("@status1", static_cast<unsigned>(UploadStatus::Uploading));
|
query.bind("@status1", static_cast<unsigned>(UploadStatus::Uploading));
|
||||||
query.bind("@status2", static_cast<unsigned>(UploadStatus::Modified));
|
query.bind("@status2", static_cast<unsigned>(UploadStatus::Modified));
|
||||||
|
// Check copying
|
||||||
if (query.executeStep())
|
if (query.executeStep())
|
||||||
{
|
{
|
||||||
if (static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(2))) == UploadStatus::Uploading)
|
if (static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(2))) == UploadStatus::Uploading)
|
||||||
@@ -172,17 +173,40 @@ void CUploadManager::AddOrUpdate(const String& siaPath, const String& filePath)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*SQLite::Statement addOrUpdate(_uploadDatabase, ADD_UPDATE_UPLOAD);
|
||||||
String tempPath;
|
|
||||||
tempPath.resize(MAX_PATH + 1);
|
|
||||||
PathCombine(&tempPath[0], CA2W(_siaDriveConfig->GetTempFolder().c_str()), GenerateSha256(filePath).c_str());
|
|
||||||
SQLite::Statement addOrUpdate(_uploadDatabase, ADD_UPDATE_UPLOAD);
|
|
||||||
addOrUpdate.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
|
addOrUpdate.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
|
||||||
addOrUpdate.bind("@file_path", CW2A(filePath.c_str()).m_psz);
|
addOrUpdate.bind("@file_path", CW2A(filePath.c_str()).m_psz);
|
||||||
addOrUpdate.bind("@temp_path", CW2A(tempPath.c_str()).m_psz);
|
addOrUpdate.bind("@temp_path", CW2A(tempPath.c_str()).m_psz);
|
||||||
addOrUpdate.bind("@status", static_cast<unsigned>(UploadStatus::Queued));
|
addOrUpdate.bind("@status", static_cast<unsigned>(UploadStatus::Queued));*/
|
||||||
|
|
||||||
|
// While copy is active, point to normal file.
|
||||||
|
// After copy, use temp file as real file until upload is complete
|
||||||
|
// This allows modifications to the file to occur in a more timely manner.
|
||||||
|
// Error Scenarios:
|
||||||
|
// Crash before db update to status copying - file will be re-uploaded automatically, if complete; otherwise, deleted
|
||||||
|
// Need to keep track of files as being copied and then there status
|
||||||
|
// Crash Scenarios:
|
||||||
|
// Crash before copy begins - on startup, check for copying status with no .siadrive
|
||||||
|
// Crash during copy - on startup, check for copying status and delete .siadrive
|
||||||
|
// Crash after copy but before db update - on startup, check for copying status and delete .siadrive
|
||||||
|
String tempPath;
|
||||||
|
tempPath.resize(MAX_PATH + 1);
|
||||||
|
PathCombine(&tempPath[0], CA2W(_siaDriveConfig->GetTempFolder().c_str()), (GenerateSha256(filePath) + L".siadrive").c_str());
|
||||||
|
|
||||||
|
// Queue this
|
||||||
|
if (::CopyFile(filePath.c_str(), tempPath.c_str(), FALSE))
|
||||||
|
{
|
||||||
tempPath = L"";
|
tempPath = L"";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!::DeleteFile(tempPath.c_str()))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
// error condition
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUploadManager::PurgeCompleteStatus()
|
void CUploadManager::PurgeCompleteStatus()
|
||||||
|
@@ -13,6 +13,7 @@ public:
|
|||||||
enum class _UploadStatus : unsigned
|
enum class _UploadStatus : unsigned
|
||||||
{
|
{
|
||||||
NotFound,
|
NotFound,
|
||||||
|
Copying,
|
||||||
Queued,
|
Queued,
|
||||||
Modified,
|
Modified,
|
||||||
Uploading,
|
Uploading,
|
||||||
|
Reference in New Issue
Block a user