1
0

Fixed column indicies

This commit is contained in:
Scott E. Graves
2017-02-25 23:32:17 -06:00
parent b7579d5e0f
commit d27a0cd636

View File

@@ -12,7 +12,7 @@ using namespace Sia::Api;
#define QUERY_UPLOADS_BY_STATUS "select id, sia_path, status from upload_table where status=@status order by id desc limit 1;"
#define QUERY_UPLOADS_BY_2_STATUS "select id, sia_path, status from upload_table where (status=@status1 or status=@status2) order by id desc limit 1;"
#define QUERY_UPLOADS_BY_SIA_PATH "select id, sia_path, status from upload_table where sia_path=@sia_path order by id desc limit 1;"
#define QUERY_UPLOADS_BY_SIA_PATH_AND_2_STATUS "select id, sia_path, sd_file_path, status from upload_table where sia_path=@sia_path and (status=@status1 or status=@status2) order by id desc limit 1;"
#define QUERY_UPLOADS_BY_SIA_PATH_AND_2_STATUS "select id, sia_path, file_path, sd_file_path, status from upload_table where sia_path=@sia_path and (status=@status1 or status=@status2) order by id desc limit 1;"
#define UPDATE_STATUS "update upload_table set status=@status where sia_path=@sia_path;"
#define INSERT_UPLOAD "insert into upload_table (sia_path, status, file_path, sd_file_path) values (@sia_path, @status, @file_path, @sd_file_path)"
@@ -217,7 +217,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
String siaPath = CA2W(query.getColumn(1)).m_psz;
String filePath = CA2W(query.getColumn(2)).m_psz;
String siaDriveFilePath = CA2W(query.getColumn(3)).m_psz;
UploadStatus uploadStatus = static_cast<UploadStatus>(query.getColumn(4).getUInt());
UploadStatus uploadStatus = static_cast<UploadStatus>(query.getColumn(3).getUInt());
auto fileList = fileTree->GetFileList();
auto it = std::find_if(fileList.begin(), fileList.end(), [&](const CSiaFilePtr& ptr)
@@ -311,7 +311,7 @@ UploadStatus CUploadManager::GetUploadStatus(const String& siaPath)
query.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
if (query.executeStep())
{
uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(2)));
uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(3)));
}
return uploadStatus;
@@ -366,7 +366,7 @@ UploadError CUploadManager::AddOrUpdate(const String& siaPath, String filePath)
// Check copying
if (query.executeStep())
{
UploadStatus uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(2)));
UploadStatus uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(4)));
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(ExistingUploadFound(siaPath, filePath, uploadStatus)));
if (uploadStatus == UploadStatus::Uploading)
{
@@ -449,7 +449,10 @@ UploadError CUploadManager::Remove(const String& siaPath)
bool remove = false;
SQLite::Statement query(_uploadDatabase, QUERY_STATUS);
query.bind("@sia_path", CW2A(siaPath.c_str()).m_psz);
if (query.executeStep())
{
}
if (remove)
{
std::lock_guard<std::mutex> l2(_fileQueueMutex);