|
|
|
@@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|