Upload list and package creation
This commit is contained in:
@@ -2,4 +2,7 @@ Work Laptop
|
||||
vitals thirsty tattoo unjustly already lexicon ruthless rated skater voyage avoid jeers aunt tawny richly glass menu kidneys went wounded wounded trendy towel lipstick raking bacon dozen blip aggravate
|
||||
|
||||
Home Laptop
|
||||
swung loudly piloted woozy foggy macro nerves dozen cunning simplest hesitate hiding gels abyss opacity cinema fierce trying rhino kiwi racetrack banjo lodge zapped wolf dusted duets upstairs acoustic
|
||||
|
||||
Home Laptop Old
|
||||
basin bobsled greater eden deftly dwarf powder intended under pact remedy neutral mime bite sphere nexus python trolling virtual sulking lordship ghetto aphid jazz village gables tapestry drinks afar
|
@@ -1,5 +1,4 @@
|
||||
@echo off
|
||||
pushd "%~dp0%"
|
||||
call build.cmd Debug
|
||||
pause
|
||||
popd
|
@@ -1,5 +1,4 @@
|
||||
@echo off
|
||||
pushd "%~dp0%"
|
||||
call build.cmd Release
|
||||
pause
|
||||
popd
|
@@ -46,7 +46,7 @@
|
||||
<label id="ID_WalletReceiveAddress" style="text-align: center; width: inherit;display: block;">...</label>
|
||||
</div>
|
||||
<div class="box" id="renter_info">
|
||||
<h1>Renter Settings <a href="javascript:void(0)" id="ID_Renter_Edit">edit</a></h1>
|
||||
<h1>Renter Settings <a href="javascript:void(0)" id="ID_Renter_Edit">edit</a> <a href="javascript:void(0)" id="ID_Renter_Uploads">uploads</a></h1>
|
||||
<table width="inherit" style="margin: 0 auto">
|
||||
<tr>
|
||||
<td style="text-align: right">Total Funding:</td>
|
||||
@@ -173,5 +173,12 @@
|
||||
<button id="ID_RenterSettingsCancel" type="button">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="upload_progress_window">
|
||||
<div class="box">
|
||||
<h1>Upload Progress</h1>
|
||||
<table style="width: 100%" id="ID_UploadProgressTable">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -79,6 +79,27 @@
|
||||
setInnerText('ID_RenterCalcStorage', '~' + res);
|
||||
});
|
||||
}
|
||||
},
|
||||
setUploadProgress: (items) => {
|
||||
const table = document.getElementById('ID_UploadProgressTable');
|
||||
while (table.rows.length > items.length) {
|
||||
table.deleteRow(table.rows.length - 1);
|
||||
}
|
||||
for (const item of items) {
|
||||
const siaPath = item['SiaPath'];
|
||||
const progress = item['Progress'];
|
||||
const row = table.getElementById('ID_Progress_' + btoa(siaPath));
|
||||
if (row) {
|
||||
row.cells[1].firstChild.value = progress;
|
||||
} else {
|
||||
const row = table.insertRow(table.rows.length);
|
||||
row.id = 'ID_Progress_' + btoa(siaPath);
|
||||
let cell = row.insertCell(0);
|
||||
cell.innerText = siaPath;
|
||||
cell = row.insertCell(1);
|
||||
cell.innerHTML = '<progress value="' + progress + '" max="100"></progress>';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#ifndef _UPLOADMANAGER_H
|
||||
#define _UPLOADMANAGER_H
|
||||
|
||||
#include <siaapi.h>
|
||||
#include <SQLiteCpp/Database.h>
|
||||
#include <SQLiteCpp/Exception.h>
|
||||
#include <autothread.h>
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
CSiaDriveConfig* _siaDriveConfig;
|
||||
SQLite::Database _uploadDatabase;
|
||||
std::mutex _uploadMutex;
|
||||
std::shared_ptr<std::vector<CSiaFilePtr>> _uploadFileList;
|
||||
|
||||
private:
|
||||
CSiaDriveConfig* GetSiaDriveConfig() const { return _siaDriveConfig; }
|
||||
@@ -68,11 +70,14 @@ public:
|
||||
CSiaError<_UploadErrorCode> AddOrUpdate(const SString& siaPath, SString filePath, const std::uint64_t& lastModified);
|
||||
_UploadStatus GetUploadStatus(const SString& siaPath);
|
||||
CSiaError<_UploadErrorCode> Remove(const SString& siaPath);
|
||||
std::shared_ptr<std::vector<CSiaFilePtr>> GetUploadFileList() const;
|
||||
};
|
||||
|
||||
typedef CUploadManager::_UploadStatus UploadStatus;
|
||||
typedef CUploadManager::_UploadErrorCode UploadErrorCode;
|
||||
typedef CSiaError<CUploadManager::_UploadErrorCode> UploadError;
|
||||
typedef std::vector<CSiaFilePtr> UploadFileList;
|
||||
typedef std::shared_ptr<UploadFileList> UploadFileListPtr;
|
||||
|
||||
NS_END(2)
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <siaapi.h>
|
||||
#include <mutex>
|
||||
#include <eventsystem.h>
|
||||
#include <uploadmanager.h>
|
||||
NS_BEGIN(Sia)
|
||||
NS_BEGIN(Api)
|
||||
NS_BEGIN(Dokan)
|
||||
@@ -47,13 +48,11 @@ private:
|
||||
std::mutex _startStopMutex;
|
||||
|
||||
public:
|
||||
bool IsMounted() const;
|
||||
|
||||
void Mount(const wchar_t& driveLetter, const SString& cacheLocation, const std::uint64_t& maxCacheSizeBytes);
|
||||
|
||||
void Unmount(const bool& clearCache = false);
|
||||
|
||||
void ClearCache();
|
||||
UploadFileListPtr GetUploadFileList() const;
|
||||
bool IsMounted() const;
|
||||
void Mount(const wchar_t& driveLetter, const SString& cacheLocation, const std::uint64_t& maxCacheSizeBytes);
|
||||
void Unmount(const bool& clearCache = false);
|
||||
};
|
||||
|
||||
NS_END(3)
|
||||
|
14
package.cmd
Normal file
14
package.cmd
Normal file
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
|
||||
set MODE=%1
|
||||
|
||||
pushd "%~dp0"
|
||||
|
||||
setlocal
|
||||
call build_%MODE%_x64.cmd
|
||||
endlocal
|
||||
|
||||
wget https://github.com/NebulousLabs/Sia/releases/download/v1.2.0/Sia-v1.2.0-windows-amd64.zip
|
||||
wget https://github.com/dokan-dev/dokany/releases/download/v1.0.3/Dokan_x64.msi
|
||||
|
||||
popd
|
5
package_debug_x64.cmd
Normal file
5
package_debug_x64.cmd
Normal file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
pushd "%~dp0%"
|
||||
call package.cmd Debug
|
||||
pause
|
||||
popd
|
5
package_release_x64.cmd
Normal file
5
package_release_x64.cmd
Normal file
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
pushd "%~dp0%"
|
||||
call package.cmd Release
|
||||
pause
|
||||
popd
|
@@ -472,6 +472,19 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
|
||||
// Display block height
|
||||
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
|
||||
|
||||
// Upload status
|
||||
auto uploadFileList = _siaDrive->GetUploadFileList();
|
||||
auto list = CefV8Value::CreateArray(uploadFileList->size());
|
||||
int idx = 0;
|
||||
for (const auto& file : *uploadFileList)
|
||||
{
|
||||
auto f = global->CreateObject(nullptr, nullptr);
|
||||
f->SetValue("SiaPath", CefV8Value::CreateString(file->GetSiaPath().str()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
f->SetValue("Progress", CefV8Value::CreateUInt(std::max(100u, file->GetUploadProgress())), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
list->SetValue(idx++, f);
|
||||
}
|
||||
ExecuteSetter(context, renterActions, "setUploadProgress", list);
|
||||
}
|
||||
|
||||
if (isOnline != wasOnline)
|
||||
|
@@ -572,6 +572,7 @@ public:
|
||||
#define UPLOAD_TABLE_COLUMNS L"id integer primary key autoincrement, sia_path text unique not null, file_path text unique not null, status integer not null, modified_time integer not null"
|
||||
#define QUERY_STATUS "select * from upload_table where sia_path=@sia_path order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_STATUS "select * from upload_table where status=@status order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_2_STATUS "select * from upload_table where status=@status1 or status=@status2 order by sia_path;"
|
||||
#define QUERY_UPLOAD_COUNT_BY_STATUS "select count(id) from upload_table where status=@status;"
|
||||
#define QUERY_UPLOADS_BY_SIA_PATH "select * from upload_table where sia_path=@sia_path order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_SIA_PATH_AND_STATUS "select * from upload_table where sia_path=@sia_path and status=@status order by id desc limit 1;"
|
||||
@@ -714,6 +715,34 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
|
||||
if (ApiSuccess(siaCurl.Get(L"/renter/files", result)))
|
||||
{
|
||||
fileTree->BuildTree(result);
|
||||
try
|
||||
{
|
||||
UploadFileListPtr uploadFileList(new UploadFileList());
|
||||
std::lock_guard<std::mutex> l(_uploadMutex);
|
||||
SQLite::Statement query(_uploadDatabase, QUERY_UPLOADS_BY_2_STATUS);
|
||||
query.bind("@status1", static_cast<unsigned>(UploadStatus::Queued));
|
||||
query.bind("@status2", static_cast<unsigned>(UploadStatus::Uploading));
|
||||
while (query.executeStep())
|
||||
{
|
||||
SString siaPath = static_cast<const char*>(query.getColumn(query.getColumnIndex("sia_path")));
|
||||
auto fileList = fileTree->GetFileList();
|
||||
auto it = std::find_if(fileList->begin(), fileList->end(), [&](const CSiaFilePtr& ptr)
|
||||
{
|
||||
return ptr->GetSiaPath() == siaPath;
|
||||
});
|
||||
|
||||
if (it != fileList->end())
|
||||
{
|
||||
uploadFileList->push_back(*it);
|
||||
}
|
||||
}
|
||||
_uploadFileList = uploadFileList;
|
||||
}
|
||||
catch (const SQLite::Exception& e)
|
||||
{
|
||||
// error condition
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DatabaseExceptionOccurred("AutoThreadCallback(uploadStatus)", e)));
|
||||
}
|
||||
|
||||
// Lock here - if file is modified again before previously queued upload is complete, delete it and
|
||||
// start again later
|
||||
@@ -724,7 +753,6 @@ 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")));
|
||||
UploadStatus uploadStatus = static_cast<UploadStatus>(query.getColumn(query.getColumnIndex("status")).getUInt());
|
||||
|
||||
auto fileList = fileTree->GetFileList();
|
||||
auto it = std::find_if(fileList->begin(), fileList->end(), [&](const CSiaFilePtr& ptr)
|
||||
@@ -903,4 +931,9 @@ UploadError CUploadManager::Remove(const SString& siaPath)
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
UploadFileListPtr CUploadManager::GetUploadFileList() const
|
||||
{
|
||||
return _uploadFileList;
|
||||
}
|
@@ -1205,7 +1205,7 @@ private:
|
||||
private:
|
||||
static CSiaApi* _siaApi;
|
||||
static CSiaDriveConfig* _siaDriveConfig;
|
||||
static std::unique_ptr<CUploadManager> _uploadManager;
|
||||
static std::shared_ptr<CUploadManager> _uploadManager;
|
||||
static DOKAN_OPERATIONS _dokanOps;
|
||||
static DOKAN_OPTIONS _dokanOptions;
|
||||
static FilePath _cacheLocation;
|
||||
@@ -1230,7 +1230,7 @@ private:
|
||||
{
|
||||
return _siaFileTree;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
static void SetCachedFileTime(const SString& filePath, T* fd)
|
||||
{
|
||||
@@ -1988,7 +1988,7 @@ private:
|
||||
|
||||
static NTSTATUS DOKAN_CALLBACK Sia_Unmounted(PDOKAN_FILE_INFO dokanFileInfo)
|
||||
{
|
||||
_uploadManager.reset(nullptr);
|
||||
_uploadManager.reset();
|
||||
StopFileListThread();
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DriveUnMounted(_mountPoint)));
|
||||
return STATUS_SUCCESS;
|
||||
@@ -2720,11 +2720,23 @@ public:
|
||||
{
|
||||
return (_siaApi != nullptr);
|
||||
}
|
||||
|
||||
static UploadFileListPtr GetUploadFileList()
|
||||
{
|
||||
auto uploadManager = _uploadManager;
|
||||
if (uploadManager)
|
||||
{
|
||||
return uploadManager->GetUploadFileList();
|
||||
}
|
||||
|
||||
return UploadFileListPtr(new UploadFileList());
|
||||
}
|
||||
};
|
||||
|
||||
// Static member variables
|
||||
CSiaApi* DokanImpl::_siaApi = nullptr;
|
||||
CSiaDriveConfig* DokanImpl::_siaDriveConfig = nullptr;
|
||||
std::unique_ptr<CUploadManager> DokanImpl::_uploadManager;
|
||||
std::shared_ptr<CUploadManager> DokanImpl::_uploadManager;
|
||||
DOKAN_OPERATIONS DokanImpl::_dokanOps;
|
||||
DOKAN_OPTIONS DokanImpl::_dokanOptions;
|
||||
FilePath DokanImpl::_cacheLocation;
|
||||
@@ -2776,4 +2788,10 @@ void CSiaDokanDrive::Unmount(const bool& clearCache)
|
||||
void CSiaDokanDrive::ClearCache()
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
}
|
||||
|
||||
UploadFileListPtr CSiaDokanDrive::GetUploadFileList() const
|
||||
{
|
||||
return DokanImpl::GetUploadFileList();
|
||||
|
||||
}
|
Reference in New Issue
Block a user