git-svn-id: svn://db.shs.com.ru/pip@416 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -541,8 +541,8 @@ bool PIBaseTransfer::finish_send(bool ok) {
|
||||
if (!ok) sendBreak(header.session_id);
|
||||
else sendReply(pt_ReplySuccess);
|
||||
mutex_header.unlock();
|
||||
sendFinished(ok);
|
||||
piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||
sendFinished(ok);
|
||||
// diag.stop();
|
||||
bytes_all = bytes_cur = 0;
|
||||
return ok;
|
||||
@@ -558,8 +558,8 @@ void PIBaseTransfer::finish_receive(bool ok, bool quet) {
|
||||
sendBreak(header.session_id);
|
||||
mutex_header.unlock();
|
||||
}
|
||||
receiveFinished(ok);
|
||||
piCoutObj << state_string << PIString::readableSize(bytes_all);
|
||||
receiveFinished(ok);
|
||||
// diag.stop();
|
||||
bytes_all = bytes_cur = 0;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
||||
// piCout << "prepare" << i << files_[i].path << files_[i].dest_path << files_[i].name();
|
||||
}
|
||||
randomize();
|
||||
step_mutex.lock();
|
||||
pftheader.session_id = randomi();
|
||||
sendFilesStarted();
|
||||
cur_file_string = "build session";
|
||||
@@ -87,17 +88,20 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
||||
pftheader.step = pft_Description;
|
||||
buildSession(PIVector<Part>() << Part(0, desc.size()));
|
||||
cur_file_string = "";
|
||||
step_mutex.unlock();
|
||||
if (!send_process()) {
|
||||
sendFilesFinished(false);
|
||||
started_ = false;
|
||||
return false;
|
||||
}
|
||||
step_mutex.lock();
|
||||
pftheader.step = pft_Data;
|
||||
PIVector<Part> pts;
|
||||
for (int i=0; i<files_.size_s(); i++) {
|
||||
pts << Part(i+1, files_[i].size);
|
||||
}
|
||||
buildSession(pts);
|
||||
step_mutex.unlock();
|
||||
bool ok = send_process();
|
||||
sendFilesFinished(ok);
|
||||
started_ = false;
|
||||
@@ -222,6 +226,7 @@ void PIFileTransfer::receivePart(PIBaseTransfer::Part fi, PIByteArray ba, PIByte
|
||||
// piCout << pheader.size() << sizeof(PFTHeader);
|
||||
pheader >> h;
|
||||
// piCout << h.session_id;
|
||||
PIMutexLocker ml(step_mutex);
|
||||
StepType st = (StepType)h.step;
|
||||
pftheader.step = st;
|
||||
if (!h.check_sig()) {
|
||||
@@ -275,7 +280,10 @@ void PIFileTransfer::receive_started() {
|
||||
|
||||
|
||||
void PIFileTransfer::receive_finished(bool ok) {
|
||||
if (pftheader.step == pft_Description) {
|
||||
step_mutex.lock();
|
||||
StepType st = (StepType)pftheader.step;
|
||||
step_mutex.unlock();
|
||||
if (st == pft_Description) {
|
||||
bool user_ok = true;
|
||||
if (ok) {
|
||||
// piCoutObj << desc.size() << PICoutManipulators::Hex << desc;
|
||||
@@ -293,7 +301,7 @@ void PIFileTransfer::receive_finished(bool ok) {
|
||||
started_ = false;
|
||||
} else resume();
|
||||
}
|
||||
if (pftheader.step == pft_Data) {
|
||||
if (st == pft_Data) {
|
||||
//piCoutObj << "file close";
|
||||
work_file.close();
|
||||
receiveFilesFinished(ok);
|
||||
|
||||
@@ -95,6 +95,7 @@ private:
|
||||
PIByteArray desc;
|
||||
PIDir scan_dir;
|
||||
bool started_, scanning;
|
||||
PIMutex step_mutex;
|
||||
|
||||
bool sendFiles(const PIVector<PFTFileInfo> &files);
|
||||
void processFile(int id, ullong start, PIByteArray &data);
|
||||
|
||||
@@ -650,7 +650,7 @@ void Daemon::peerDisconnected(const PIString & p_name) {
|
||||
|
||||
|
||||
void Daemon::filesReceived(const PIString & p_name, bool ok) {
|
||||
piCoutObj << "filesReceived";
|
||||
piCout << "filesReceived";
|
||||
closeFileDialog(p_name, ok);
|
||||
PIMutexLocker ml(remote_mutex);
|
||||
Remote * r = remotes.value(p_name, 0);
|
||||
@@ -660,7 +660,7 @@ void Daemon::filesReceived(const PIString & p_name, bool ok) {
|
||||
|
||||
|
||||
void Daemon::filesSended(const PIString & p_name, bool ok) {
|
||||
piCoutObj << "filesSended";
|
||||
piCout << "filesSended";
|
||||
closeFileDialog(p_name, ok);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user