From e88ded9ebf52faf7fdfbd85970f59d8df3b095d5 Mon Sep 17 00:00:00 2001 From: maliang Date: Fri, 22 Aug 2025 11:51:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E8=B7=AF=E5=BE=84=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maliang --- src/common/file.cpp | 5 +++-- src/common/transfer.cpp | 36 +++++++++++++++++++++++------------- src/common/transfer.h | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/common/file.cpp b/src/common/file.cpp index 9001a3d6..645ea274 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -529,10 +529,11 @@ void HdcFile::TransferNext(CtxFile *context) context->localPath = context->localDirName + context->localName; context->taskQueue.pop_back(); WRITE_LOG(LOG_DEBUG, "TransferNext localPath = %s queuesize:%d", - context->localPath.c_str(), ctxNow.taskQueue.size()); + Hdc::MaskString(context->localPath).c_str(), ctxNow.taskQueue.size()); uv_fs_t *openReq = new uv_fs_t; if (openReq == nullptr) { - WRITE_LOG(LOG_FATAL, "HdcFile::TransferNext new openReq failed for file %s", context->localPath.c_str()); + WRITE_LOG(LOG_FATAL, "HdcFile::TransferNext new openReq failed for file %s", + Hdc::MaskString(context->localPath).c_str()); OnFileOpenFailed(context); return; } diff --git a/src/common/transfer.cpp b/src/common/transfer.cpp index 4eac6129..f4a2c9f8 100644 --- a/src/common/transfer.cpp +++ b/src/common/transfer.cpp @@ -201,7 +201,8 @@ bool HdcTransferBase::SendIOPayload(CtxFile *context, uint64_t index, uint8_t *d compressSize = LZ4_compress_default((const char *)data, (char *)sendBuf + payloadPrefixReserve, dataSize, dataSize); if (compressSize <= 0) { - WRITE_LOG(LOG_DEBUG, "LZ4 compress failed, path: %s compress none", context->localPath.c_str()); + WRITE_LOG(LOG_DEBUG, "LZ4 compress failed, path: %s compress none", + Hdc::MaskString(context->localPath).c_str()); delete[] sendBuf; payloadHead.compressType = COMPRESS_NONE; compressSize = dataSize; @@ -276,7 +277,7 @@ bool HdcTransferBase::ProcressFileIORead(uv_fs_t *req, CtxFile *context, HdcTran return true; } if (req->result == 0) { - WRITE_LOG(LOG_DEBUG, "path:%s fd:%d eof", context->localPath.c_str(), context->openFd); + WRITE_LOG(LOG_DEBUG, "path:%s fd:%d eof", Hdc::MaskString(context->localPath).c_str(), context->openFd); return true; } if (context->indexIO < context->fileSize) { @@ -340,15 +341,19 @@ bool HdcTransferBase::ProcressFileIOIsSuccess(uv_fs_t *req, CtxFile *context, ui uv_fs_t fs = {}; int ret = uv_fs_statfs(nullptr, &fs, context->localPath.c_str(), nullptr); if (ret < 0) { + constexpr int size = 1024; + char buf[size] = { 0 }; + uv_strerror_r(ret, buf, size); WRITE_LOG(LOG_WARN, "CheckSpace error querying filesystem: %s, path: %s", - uv_strerror(ret), context->localPath.c_str()); + buf, Hdc::MaskString(context->localPath).c_str()); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast(abs(ret)); return false; } uv_statfs_t* statfs = static_cast(fs.ptr); uint64_t freeBytes = statfs->f_bsize * statfs->f_bfree; - WRITE_LOG(LOG_DEBUG, "CheckSpace, path: %s, freeBytes: %llu", context->localPath.c_str(), freeBytes); + WRITE_LOG(LOG_DEBUG, "CheckSpace, path: %s, freeBytes: %llu", + Hdc::MaskString(context->localPath).c_str(), freeBytes); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast((freeBytes == 0) ? ENOSPC : EIO); return false; @@ -439,7 +444,8 @@ void HdcTransferBase::RemoveSandboxRootPath(std::string &srcStr, const std::stri if ((pos = srcStr.find(fullPath)) != std::string::npos) { srcStr = srcStr.replace(pos, fullPath.length(), ""); } else { - WRITE_LOG(LOG_DEBUG, "fullPath:%s, srcStr:%s", fullPath.c_str(), srcStr.c_str()); + WRITE_LOG(LOG_DEBUG, "fullPath:%s, srcStr:%s", Hdc::MaskString(fullPath).c_str(), + Hdc::MaskString(srcStr).c_str()); } } @@ -451,7 +457,7 @@ void HdcTransferBase::OnFileOpen(uv_fs_t *req) StartTraceScope("HdcTransferBase::OnFileOpen"); uv_fs_req_cleanup(req); WRITE_LOG(LOG_DEBUG, "Filemod openfile:%s channelId:%u result:%d", - context->localPath.c_str(), thisClass->taskInfo->channelId, req->result); + Hdc::MaskString(context->localPath).c_str(), thisClass->taskInfo->channelId, req->result); --thisClass->refCount; if (req->result <= 0) { constexpr int bufSize = 1024; @@ -461,8 +467,9 @@ void HdcTransferBase::OnFileOpen(uv_fs_t *req) thisClass->RemoveSandboxRootPath(localPath, context->bundleName); thisClass->LogMsg(MSG_FAIL, "Error opening file: %s, path:%s", buf, localPath.c_str()); - WRITE_LOG(LOG_FATAL, "open path:%s, localPath:%s, error:%s, dir:%d, master:%d", context->localPath.c_str(), - localPath.c_str(), buf, context->isDir, context->master); + WRITE_LOG(LOG_FATAL, "open path:%s, localPath:%s, error:%s, dir:%d, master:%d", + Hdc::MaskString(context->localPath).c_str(), + Hdc::MaskString(localPath).c_str(), buf, context->isDir, context->master); OnFileOpenFailed(context); return; } @@ -636,7 +643,8 @@ int HdcTransferBase::GetSubFilesRecursively(string path, string currentDirname, bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string &errStr) { // If optName show this is directory mode, check localPath and try create each layer - WRITE_LOG(LOG_DEBUG, "CheckDirectory localPath = %s optName = %s", localPath.c_str(), optName.c_str()); + WRITE_LOG(LOG_DEBUG, "CheckDirectory localPath = %s optName = %s", + Hdc::MaskString(localPath).c_str(), optName.c_str()); if ((optName.find('/') == string::npos) && (optName.find('\\') == string::npos)) { WRITE_LOG(LOG_DEBUG, "Not directory mode optName = %s, return", optName.c_str()); return true; @@ -653,13 +661,14 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string if (dirsOflocalPath.size() > 0 && !ctxNow.isDir && localPath.back() != Base::GetPathSep()) { dirsOflocalPath.pop_back(); } - WRITE_LOG(LOG_DEBUG, "localPath = %s dir layers = %zu", localPath.c_str(), dirsOflocalPath.size()); + WRITE_LOG(LOG_DEBUG, "localPath = %s dir layers = %zu", + Hdc::MaskString(localPath).c_str(), dirsOflocalPath.size()); string makedirPath; if (!Base::IsAbsolutePath(localPath)) { makedirPath = "."; } for (auto dir : dirsOflocalPath) { - WRITE_LOG(LOG_DEBUG, "CheckLocalPath create dir = %s", dir.c_str()); + WRITE_LOG(LOG_DEBUG, "CheckLocalPath create dir = %s", Hdc::MaskString(dir).c_str()); if (dir == ".") { continue; @@ -679,7 +688,7 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string // set flag to remove first layer directory of filename from master ctxNow.targetDirNotExist = true; } else if (ctxNow.isDir && !(mode & S_IFDIR)) { - WRITE_LOG(LOG_WARN, "Not a directory, path:%s", localPath.c_str()); + WRITE_LOG(LOG_WARN, "Not a directory, path:%s", Hdc::MaskString(localPath).c_str()); errStr = "Not a directory, path:" + localPath; return false; } @@ -747,7 +756,8 @@ bool HdcTransferBase::CheckFilename(string &localPath, string &optName, string & } } - WRITE_LOG(LOG_DEBUG, "CheckFilename finish localPath:%s optName:%s", localPath.c_str(), optName.c_str()); + WRITE_LOG(LOG_DEBUG, "CheckFilename finish localPath:%s optName:%s", + Hdc::MaskString(localPath).c_str(), optName.c_str()); return true; } diff --git a/src/common/transfer.h b/src/common/transfer.h index 7c54d871..c9a11eeb 100644 --- a/src/common/transfer.h +++ b/src/common/transfer.h @@ -150,7 +150,7 @@ protected: return; } WRITE_LOG(LOG_DEBUG, "CloseCtxFd, localPath:%s result:%d, closeReqSubmitted:%d", - context->localPath.c_str(), context->openFd, context->closeReqSubmitted); + Hdc::MaskString(context->localPath).c_str(), context->openFd, context->closeReqSubmitted); uv_fs_t fs; uv_fs_close(nullptr, &fs, context->openFd, nullptr); uv_fs_req_cleanup(&fs); -- Gitee From 5789ec507782145ac1957b8a6878cfeba304ac2f Mon Sep 17 00:00:00 2001 From: maliang Date: Fri, 22 Aug 2025 12:01:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=E8=B7=AF=E5=BE=84=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: maliang --- src/common/transfer.cpp | 22 +++++++++++----------- src/host/server_for_client.cpp | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/common/transfer.cpp b/src/common/transfer.cpp index f4a2c9f8..92c98d2b 100644 --- a/src/common/transfer.cpp +++ b/src/common/transfer.cpp @@ -202,7 +202,7 @@ bool HdcTransferBase::SendIOPayload(CtxFile *context, uint64_t index, uint8_t *d dataSize, dataSize); if (compressSize <= 0) { WRITE_LOG(LOG_DEBUG, "LZ4 compress failed, path: %s compress none", - Hdc::MaskString(context->localPath).c_str()); + context->localPath.c_str()); delete[] sendBuf; payloadHead.compressType = COMPRESS_NONE; compressSize = dataSize; @@ -277,7 +277,7 @@ bool HdcTransferBase::ProcressFileIORead(uv_fs_t *req, CtxFile *context, HdcTran return true; } if (req->result == 0) { - WRITE_LOG(LOG_DEBUG, "path:%s fd:%d eof", Hdc::MaskString(context->localPath).c_str(), context->openFd); + WRITE_LOG(LOG_DEBUG, "path:%s fd:%d eof", context->localPath.c_str(), context->openFd); return true; } if (context->indexIO < context->fileSize) { @@ -345,7 +345,7 @@ bool HdcTransferBase::ProcressFileIOIsSuccess(uv_fs_t *req, CtxFile *context, ui char buf[size] = { 0 }; uv_strerror_r(ret, buf, size); WRITE_LOG(LOG_WARN, "CheckSpace error querying filesystem: %s, path: %s", - buf, Hdc::MaskString(context->localPath).c_str()); + buf, context->localPath.c_str()); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast(abs(ret)); return false; @@ -353,7 +353,7 @@ bool HdcTransferBase::ProcressFileIOIsSuccess(uv_fs_t *req, CtxFile *context, ui uv_statfs_t* statfs = static_cast(fs.ptr); uint64_t freeBytes = statfs->f_bsize * statfs->f_bfree; WRITE_LOG(LOG_DEBUG, "CheckSpace, path: %s, freeBytes: %llu", - Hdc::MaskString(context->localPath).c_str(), freeBytes); + context->localPath.c_str(), freeBytes); uv_fs_req_cleanup(&fs); context->lastErrno = static_cast((freeBytes == 0) ? ENOSPC : EIO); return false; @@ -457,7 +457,7 @@ void HdcTransferBase::OnFileOpen(uv_fs_t *req) StartTraceScope("HdcTransferBase::OnFileOpen"); uv_fs_req_cleanup(req); WRITE_LOG(LOG_DEBUG, "Filemod openfile:%s channelId:%u result:%d", - Hdc::MaskString(context->localPath).c_str(), thisClass->taskInfo->channelId, req->result); + context->localPath.c_str(), thisClass->taskInfo->channelId, req->result); --thisClass->refCount; if (req->result <= 0) { constexpr int bufSize = 1024; @@ -468,8 +468,8 @@ void HdcTransferBase::OnFileOpen(uv_fs_t *req) thisClass->LogMsg(MSG_FAIL, "Error opening file: %s, path:%s", buf, localPath.c_str()); WRITE_LOG(LOG_FATAL, "open path:%s, localPath:%s, error:%s, dir:%d, master:%d", - Hdc::MaskString(context->localPath).c_str(), - Hdc::MaskString(localPath).c_str(), buf, context->isDir, context->master); + context->localPath.c_str(), + localPath.c_str(), buf, context->isDir, context->master); OnFileOpenFailed(context); return; } @@ -644,7 +644,7 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string { // If optName show this is directory mode, check localPath and try create each layer WRITE_LOG(LOG_DEBUG, "CheckDirectory localPath = %s optName = %s", - Hdc::MaskString(localPath).c_str(), optName.c_str()); + localPath.c_str(), optName.c_str()); if ((optName.find('/') == string::npos) && (optName.find('\\') == string::npos)) { WRITE_LOG(LOG_DEBUG, "Not directory mode optName = %s, return", optName.c_str()); return true; @@ -662,13 +662,13 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string dirsOflocalPath.pop_back(); } WRITE_LOG(LOG_DEBUG, "localPath = %s dir layers = %zu", - Hdc::MaskString(localPath).c_str(), dirsOflocalPath.size()); + localPath.c_str(), dirsOflocalPath.size()); string makedirPath; if (!Base::IsAbsolutePath(localPath)) { makedirPath = "."; } for (auto dir : dirsOflocalPath) { - WRITE_LOG(LOG_DEBUG, "CheckLocalPath create dir = %s", Hdc::MaskString(dir).c_str()); + WRITE_LOG(LOG_DEBUG, "CheckLocalPath create dir = %s", dir.c_str()); if (dir == ".") { continue; @@ -688,7 +688,7 @@ bool HdcTransferBase::CheckLocalPath(string &localPath, string &optName, string // set flag to remove first layer directory of filename from master ctxNow.targetDirNotExist = true; } else if (ctxNow.isDir && !(mode & S_IFDIR)) { - WRITE_LOG(LOG_WARN, "Not a directory, path:%s", Hdc::MaskString(localPath).c_str()); + WRITE_LOG(LOG_WARN, "Not a directory, path:%s", localPath.c_str()); errStr = "Not a directory, path:" + localPath; return false; } diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index 0e5a202d..19166e40 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -630,7 +630,7 @@ void HdcServerForClient::HandleRemote(HChannel hChannel, string ¶meters, Rem string remote = CMDSTR_REMOTE_PARAMETER + " "; if (parameters.find(remote) != std::string::npos) { parameters.replace(parameters.find(remote), remote.size(), ""); - WRITE_LOG(LOG_DEBUG, "parameters: %s", parameters.c_str()); + WRITE_LOG(LOG_DEBUG, "parameters: %s", Hdc::MaskString(parameters).c_str()); } } delete[](reinterpret_cast(argv)); @@ -880,8 +880,8 @@ int HdcServerForClient::ReadChannel(HChannel hChannel, uint8_t *bufPtr, const in EchoClient(hChannel, MSG_FAIL, retEcho.c_str()); } } - WRITE_LOG(LOG_DEBUG, "ReadChannel cid:%u sid:%u key:%s command: %s", - hChannel->channelId, hChannel->targetSessionId, Hdc::MaskString(hChannel->connectKey).c_str(), bufPtr); + WRITE_LOG(LOG_DEBUG, "ReadChannel cid:%u sid:%u key:%s", hChannel->channelId, + hChannel->targetSessionId, Hdc::MaskString(hChannel->connectKey).c_str()); if (formatCommand.bJumpDo) { WRITE_LOG(LOG_FATAL, "ReadChannel bJumpDo true"); return -10; // -10 error formatCommand -- Gitee