Lines Matching defs:context
38 bool HdcFile::BeginTransfer(CtxFile *context, const string &command)
51 if (!SetMasterParameters(context, command.c_str(), argc, argv)) {
62 openReq->data = context;
65 uv_fs_open(loopTask, openReq, context->localPath.c_str(), O_RDONLY, S_IWUSR | S_IRUSR, OnFileOpen);
66 context->master = true;
70 LogMsg(MSG_FAIL, "Transfer path failed, Master:%s Slave:%s", context->localPath.c_str(),
71 context->remotePath.c_str());
77 bool HdcFile::SetMasterParameters(CtxFile *context, const char *command, int argc, char **argv)
88 context->transferConfig.compressType = COMPRESS_LZ4;
91 context->transferConfig.updateIfNew = true;
98 context->transferConfig.holdTimestamp = true;
101 context->transferConfig.clientCwd = argv[i + 1];
104 context->fileModeSync = true;
117 context->remotePath = argv[argc - 1];
118 context->localPath = argv[argc - CMD_FILE_PENULT_PARAM];
125 ExtractRelativePath(context->transferConfig.clientCwd, context->localPath);
128 context->remotePath = ".";
129 context->localPath = argv[argc - 1];
133 context->localName = Base::GetFullFilePath(context->localPath);
136 if (!Base::CheckDirectoryOrPath(context->localPath.c_str(), true, true, errStr, mode) && (mode & S_IFDIR)) {
137 context->isDir = true;
138 GetSubFilesRecursively(context->localPath, context->localName, &context->taskQueue);
139 if (context->taskQueue.size() == 0) {
143 context->fileCnt = 0;
144 context->dirSize = 0;
145 context->localDirName = Base::GetPathWithoutFilename(context->localPath);
147 WRITE_LOG(LOG_DEBUG, "localDirName = %s", context->localDirName.c_str());
149 context->localName = context->taskQueue.back();
150 context->localPath = context->localDirName + context->localName;
152 WRITE_LOG(LOG_DEBUG, "localPath = %s", context->localPath.c_str());
153 context->taskQueue.pop_back();
158 void HdcFile::CheckMaster(CtxFile *context)
161 if (context->fileModeSync) {
162 string s = SerialStruct::SerializeToString(context->fileMode);
165 string s = SerialStruct::SerializeToString(context->transferConfig);
170 void HdcFile::WhenTransferFinish(CtxFile *context)
172 WRITE_LOG(LOG_DEBUG, "WhenTransferFinish fileCnt:%d", context->fileCnt);
174 context->fileCnt++;
175 context->dirSize += context->indexIO;
179 void HdcFile::TransferSummary(CtxFile *context)
182 (context->fileCnt > 1 ? context->transferDirBegin : context->transferBegin);
183 uint64_t fSize = context->fileCnt > 1 ? context->dirSize : context->indexIO;
185 if (context->indexIO >= context->fileSize || context->lastErrno == 0) {
187 fSize, context->fileCnt, nMSec, fRate);
191 uv_strerror_r(static_cast<int>(-context->lastErrno), buf, bufSize);
192 LogMsg(MSG_FAIL, "Transfer Stop at:%lld/%lld(Bytes), Reason: %s", context->indexIO, context->fileSize,
206 mode.fullName.c_str(), mode.perm, mode.uId, mode.gId, mode.context.c_str());
223 WRITE_LOG(LOG_DEBUG, "file = %s permissions: %o uId = %u, gId = %u context = %s",
224 dirMode.fullName.c_str(), dirMode.perm, dirMode.uId, dirMode.gId, dirMode.context.c_str());
245 WRITE_LOG(LOG_DEBUG, "dir = %s permissions: %o uId = %u, gId = %u context = %s",
246 dirMode.fullName.c_str(), dirMode.perm, dirMode.uId, dirMode.gId, dirMode.context.c_str());
309 void HdcFile::TransferNext(CtxFile *context)
311 context->localName = context->taskQueue.back();
312 context->localPath = context->localDirName + context->localName;
313 context->taskQueue.pop_back();
315 context->localPath.c_str(), ctxNow.taskQueue.size());
318 WRITE_LOG(LOG_FATAL, "HdcFile::TransferNext new openReq failed for file %s", context->localPath.c_str());
319 OnFileOpenFailed(context);
323 openReq->data = context;
326 uv_fs_open(loopTask, openReq, context->localPath.c_str(), O_RDONLY, S_IWUSR | S_IRUSR, OnFileOpen);