Upload manager changes
This commit is contained in:
@@ -107,6 +107,21 @@ CUploadManager::CUploadManager(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriv
|
|||||||
throw StartupException(L"Failed to remove '.siadrive.temp' files");
|
throw StartupException(L"Failed to remove '.siadrive.temp' files");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateQueueOnStartup();
|
||||||
|
DeleteFilesRemovedFromSia(siaCurl, siaDriveConfig, true);
|
||||||
|
|
||||||
|
StartAutoThread();
|
||||||
|
_fileThread.StartAutoThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
CUploadManager::~CUploadManager()
|
||||||
|
{
|
||||||
|
_fileThread.StopAutoThread();
|
||||||
|
StopAutoThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUploadManager::UpdateQueueOnStartup()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Re-add Copying and Remove
|
// Re-add Copying and Remove
|
||||||
@@ -149,15 +164,25 @@ CUploadManager::CUploadManager(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriv
|
|||||||
{
|
{
|
||||||
throw StartupException(e.getErrorStr());
|
throw StartupException(e.getErrorStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
StartAutoThread();
|
|
||||||
_fileThread.StartAutoThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CUploadManager::~CUploadManager()
|
void CUploadManager::DeleteFilesRemovedFromSia(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig, const bool& isStartup)
|
||||||
{
|
{
|
||||||
_fileThread.StopAutoThread();
|
CSiaFileTreePtr fileTree(new CSiaFileTree(siaCurl, siaDriveConfig));
|
||||||
StopAutoThread();
|
json result;
|
||||||
|
SiaCurlError cerror = siaCurl.Get(L"/renter/files", result);
|
||||||
|
if (ApiSuccess(cerror))
|
||||||
|
{
|
||||||
|
fileTree->BuildTree(result);
|
||||||
|
auto fileList = fileTree->GetFileList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isStartup)
|
||||||
|
{
|
||||||
|
throw StartupException(L"Failed to get Sia files");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUploadManager::FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
void CUploadManager::FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
||||||
@@ -621,6 +646,7 @@ UploadError CUploadManager::Remove(const String& siaPath)
|
|||||||
UploadStatus uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(query.getColumnIndex("status"))));
|
UploadStatus uploadStatus = static_cast<UploadStatus>(static_cast<unsigned>(query.getColumn(query.getColumnIndex("status"))));
|
||||||
switch (uploadStatus)
|
switch (uploadStatus)
|
||||||
{
|
{
|
||||||
|
case UploadStatus::Complete:
|
||||||
case UploadStatus::Queued:
|
case UploadStatus::Queued:
|
||||||
case UploadStatus::Modified:
|
case UploadStatus::Modified:
|
||||||
case UploadStatus::Copying:
|
case UploadStatus::Copying:
|
||||||
|
@@ -60,6 +60,8 @@ private:
|
|||||||
void FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
void FileThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
|
||||||
void HandleFileRemove(const CSiaCurl& siaCurl, const String& siaPath, const String& siaDriveFilePath);
|
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);
|
void HandleAddFile(const String& siaPath, const String& filePath, const String& tempSourcePath, const String& siaDriveFilePath);
|
||||||
|
void UpdateQueueOnStartup();
|
||||||
|
void DeleteFilesRemovedFromSia(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig, const bool& isStartup = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig) override;
|
virtual void AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig) override;
|
||||||
@@ -69,7 +71,6 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
_UploadStatus GetUploadStatus(const String& siaPath);
|
_UploadStatus GetUploadStatus(const String& siaPath);
|
||||||
void do_work(String& filePath, String& rootPath);
|
|
||||||
_UploadError AddOrUpdate(const String& siaPath, String filePath);
|
_UploadError AddOrUpdate(const String& siaPath, String filePath);
|
||||||
_UploadError Remove(const String& siaPath);
|
_UploadError Remove(const String& siaPath);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user