Complete file browser operations when command posting fails
This commit is contained in:
1 parent
7d789f68d4
commit
bc90e88e72
2 files changed
+25
-45
No files matched your search
@@ -12,7 +12,6 @@
|
||||
#include <cstring>
|
||||
extern "C" {
|
||||
#include "member_files/member_files.h"
|
||||
#include "mem.h"
|
||||
#include "debug_config.h"
|
||||
}
|
||||
|
||||
@@ -35,10 +34,7 @@ MemberFileBatch::~MemberFileBatch() {
|
||||
}
|
||||
|
||||
void MemberFileBatch::cancelRequest(quint64 id) {
|
||||
if (!id || !gui_bridge_is_uasync_ready()) return;
|
||||
auto* q = (mf_cancel_request*)u_calloc(1, sizeof(mf_cancel_request));
|
||||
if (!q) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "file batch: cancel allocation failed id=%llu", (unsigned long long)id); return; }
|
||||
q->inst = gui_bridge_get_inst(); q->id = id; gui_bridge_post_uasync_fn(member_files_gui_cancel, q);
|
||||
if (id) gui_bridge_member_files_cancel(id);
|
||||
}
|
||||
|
||||
// Сначала проверяем всё локальное дерево; до успешного обхода сервер не изменяется.
|
||||
@@ -118,20 +114,16 @@ void MemberFileBatch::start(const QList<MemberFileEntry>& entries, const QString
|
||||
}
|
||||
|
||||
void MemberFileBatch::request(uint8_t command) {
|
||||
auto* q = (mf_gui_request*)u_calloc(1, sizeof(mf_gui_request));
|
||||
if (!q || !gui_bridge_is_uasync_ready()) {
|
||||
u_free(q); finish(text("Unable to request directory")); return;
|
||||
}
|
||||
const auto& entry = m_queue.first();
|
||||
q->inst = gui_bridge_get_inst(); q->group = m_group; q->server = m_server;
|
||||
auto& r = q->message; r.kind = MF_REQUEST; r.command = command; r.owner = m_owner; r.request_id = nextId();
|
||||
mf_message r{}; r.kind = MF_REQUEST; r.command = command; r.owner = m_owner; r.request_id = nextId();
|
||||
memcpy(r.path, entry.remote.toUtf8().constData(), entry.remote.toUtf8().size());
|
||||
if ((m_mode == Download || command == MF_REMOVE_PATH || command == MF_LIST) && entry.version.size() == 16)
|
||||
memcpy(r.version, entry.version.constData(), 16);
|
||||
r.cursor = command == MF_LIST ? entry.cursor : 0; m_command = command; m_request = r.request_id;
|
||||
r.cursor = command == MF_LIST ? entry.cursor : 0;
|
||||
if (gui_bridge_member_files_request(m_group, m_server, &r) < 0) { finish(text("Unable to request directory")); return; }
|
||||
m_command = command; m_request = r.request_id;
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_MEDIA, "file batch: request id=%llu command=%s path=%s cursor=%llu",
|
||||
(unsigned long long)m_request, mf_command_text(command), r.path, (unsigned long long)r.cursor);
|
||||
gui_bridge_post_uasync_fn(member_files_gui_request, q);
|
||||
}
|
||||
|
||||
void MemberFileBatch::next() {
|
||||
@@ -241,15 +233,14 @@ bool MemberFileBatch::response(const mf_message& r) {
|
||||
}
|
||||
|
||||
void MemberFileBatch::copyFile(const QByteArray& version) {
|
||||
auto* q = (mf_transfer_request*)u_calloc(1, sizeof(mf_transfer_request));
|
||||
if (!q || !gui_bridge_is_uasync_ready()) { u_free(q); finish(text("Unable to start transfer")); return; }
|
||||
const auto& e = m_queue.first();
|
||||
q->inst = gui_bridge_get_inst(); q->id = nextId(); q->group = m_group; q->server = m_server; q->owner = m_owner;
|
||||
q->upload = m_mode == Upload;
|
||||
memcpy(q->remote, e.remote.toUtf8().constData(), e.remote.toUtf8().size());
|
||||
memcpy(q->local, e.local.toUtf8().constData(), e.local.toUtf8().size());
|
||||
if (version.size() == 16) memcpy(q->version, version.constData(), 16);
|
||||
m_transfer = q->id; gui_bridge_post_uasync_fn(member_files_gui_transfer, q);
|
||||
mf_transfer_request q{}; q.id = nextId(); q.group = m_group; q.server = m_server; q.owner = m_owner;
|
||||
q.upload = m_mode == Upload;
|
||||
memcpy(q.remote, e.remote.toUtf8().constData(), e.remote.toUtf8().size());
|
||||
memcpy(q.local, e.local.toUtf8().constData(), e.local.toUtf8().size());
|
||||
if (version.size() == 16) memcpy(q.version, version.constData(), 16);
|
||||
if (gui_bridge_member_files_transfer(&q) < 0) { finish(text("Unable to start transfer")); return; }
|
||||
m_transfer = q.id;
|
||||
}
|
||||
|
||||
bool MemberFileBatch::transfer(const uint8_t* data, int length) {
|
||||
|
||||
Reference in new issue
Block a user