Remove changes and refactoring
This commit is contained in:
@@ -129,15 +129,8 @@ void CUploadManager::FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
|
||||
}
|
||||
}
|
||||
|
||||
void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath, const bool& remove)
|
||||
void CUploadManager::HandleFileRemove(const CSiaCurl& siaCurl, const String& siaPath, const String& siaDriveFilePath)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_fileActionMutex);
|
||||
_activeSiaPath = siaPath;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_uploadMutex);
|
||||
@@ -147,9 +140,10 @@ void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath,
|
||||
{
|
||||
String removeFilePath = CA2W(query.getColumn(3)).m_psz;
|
||||
UploadStatus uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(5)));
|
||||
// Make sure status is still remove
|
||||
if (uploadStatus == UploadStatus::Remove)
|
||||
{
|
||||
bool deleteFromDb = false;
|
||||
bool deleteFromDb = true;
|
||||
if (::PathFileExists(removeFilePath.c_str()))
|
||||
{
|
||||
if (RetryDeleteFileIfExists(removeFilePath.c_str()))
|
||||
@@ -158,12 +152,11 @@ void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath,
|
||||
{
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DeleteSiaDriveFileFailed(siaPath, removeFilePath, siaDriveFilePath)));
|
||||
}
|
||||
|
||||
deleteFromDb = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(RemoveFileFailed(siaPath, removeFilePath)));
|
||||
deleteFromDb = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,10 +192,11 @@ void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath,
|
||||
{
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred(e)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check for retry queue condition
|
||||
}
|
||||
|
||||
void CUploadManager::HandleAddFile(const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath)
|
||||
{
|
||||
// Check for retry condition
|
||||
if (!::PathFileExists(tempSourcePath.c_str()) && ::PathFileExists(siaDriveFilePath.c_str()))
|
||||
{
|
||||
try
|
||||
@@ -294,6 +288,22 @@ void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath,
|
||||
// Requeued
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CUploadManager::FileAction(const CSiaCurl& siaCurl, const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath, const bool& remove)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_fileActionMutex);
|
||||
_activeSiaPath = siaPath;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
HandleFileRemove(siaCurl, siaPath, siaDriveFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleAddFile(siaPath, filePath, tempSourcePath, siaDriveFilePath);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -538,16 +548,6 @@ UploadError CUploadManager::AddOrUpdate(const String& siaPath, String filePath)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CUploadManager::PurgeCompleteStatus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CUploadManager::PurgeErrorStatus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UploadError CUploadManager::Remove(const String& siaPath)
|
||||
{
|
||||
UploadError ret = UploadError::Success;
|
||||
|
@@ -57,10 +57,12 @@ private:
|
||||
|
||||
private:
|
||||
void FileAction(const CSiaCurl& siaCurl, const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath, const bool& remove);
|
||||
void FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
||||
void HandleFileRemove(const CSiaCurl& siaCurl, const String& siaPath, const String& siaDriveFilePath);
|
||||
void HandleAddFile(const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath);
|
||||
|
||||
protected:
|
||||
virtual void AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig) override;
|
||||
void FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
||||
|
||||
public:
|
||||
static String UploadStatusToString(const _UploadStatus& uploadStatus);
|
||||
@@ -69,8 +71,6 @@ public:
|
||||
_UploadStatus GetUploadStatus(const String& siaPath);
|
||||
_UploadError AddOrUpdate(const String& siaPath, String filePath);
|
||||
_UploadError Remove(const String& siaPath);
|
||||
void PurgeCompleteStatus();
|
||||
void PurgeErrorStatus();
|
||||
};
|
||||
|
||||
typedef Sia::Api::CUploadManager::_UploadStatus UploadStatus;
|
||||
|
Reference in New Issue
Block a user