| 1136 | } |
| 1137 | |
| 1138 | void Synchronizer::executeTask(SynchronizerFileItem *task) |
| 1139 | { |
| 1140 | QString leftDirName = task->leftDirectory(); |
| 1141 | if (!leftDirName.isEmpty()) |
| 1142 | leftDirName += '/'; |
| 1143 | QString rightDirName = task->rightDirectory(); |
| 1144 | if (!rightDirName.isEmpty()) |
| 1145 | rightDirName += '/'; |
| 1146 | |
| 1147 | QUrl leftURL = Synchronizer::fsUrl(leftBaseDir + leftDirName + task->leftName()); |
| 1148 | QUrl rightURL = Synchronizer::fsUrl(rightBaseDir + rightDirName + task->rightName()); |
| 1149 | |
| 1150 | switch (task->task()) { |
| 1151 | case TT_COPY_TO_LEFT: |
| 1152 | if (task->isDir()) { |
| 1153 | KIO::SimpleJob *job = KIO::mkdir(leftURL); |
| 1154 | connect(job, &KIO::MkdirJob::result, this, &Synchronizer::slotTaskFinished); |
| 1155 | jobMap[job] = task; |
| 1156 | disableNewTasks = true; |
| 1157 | } else { |
| 1158 | QUrl destURL(leftURL); |
| 1159 | if (!task->destination().isNull()) |
| 1160 | destURL = Synchronizer::fsUrl(task->destination()); |
| 1161 | |
| 1162 | if (task->rightLink().isNull()) { |
| 1163 | KIO::FileCopyJob *job = |
| 1164 | KIO::file_copy(rightURL, destURL, -1, ((overWrite || task->overWrite()) ? KIO::Overwrite : KIO::DefaultFlags) | KIO::HideProgressInfo); |
| 1165 | connect(job, SIGNAL(processedSize(KJob *, qulonglong)), this, SLOT(slotProcessedSize(KJob *, qulonglong))); |
| 1166 | connect(job, &KIO::FileCopyJob::result, this, &Synchronizer::slotTaskFinished); |
| 1167 | jobMap[job] = task; |
| 1168 | } else { |
| 1169 | KIO::SimpleJob *job = |
| 1170 | KIO::symlink(task->rightLink(), destURL, ((overWrite || task->overWrite()) ? KIO::Overwrite : KIO::DefaultFlags) | KIO::HideProgressInfo); |
| 1171 | connect(job, &KIO::SimpleJob::result, this, &Synchronizer::slotTaskFinished); |
| 1172 | jobMap[job] = task; |
| 1173 | } |
| 1174 | } |
| 1175 | break; |
| 1176 | case TT_COPY_TO_RIGHT: |
| 1177 | if (task->isDir()) { |
| 1178 | KIO::SimpleJob *job = KIO::mkdir(rightURL); |
| 1179 | connect(job, &KIO::SimpleJob::result, this, &Synchronizer::slotTaskFinished); |
| 1180 | jobMap[job] = task; |
| 1181 | disableNewTasks = true; |
| 1182 | } else { |
| 1183 | QUrl destURL(rightURL); |
| 1184 | if (!task->destination().isNull()) |
| 1185 | destURL = Synchronizer::fsUrl(task->destination()); |
| 1186 | |
| 1187 | if (task->leftLink().isNull()) { |
| 1188 | KIO::FileCopyJob *job = |
| 1189 | KIO::file_copy(leftURL, destURL, -1, ((overWrite || task->overWrite()) ? KIO::Overwrite : KIO::DefaultFlags) | KIO::HideProgressInfo); |
| 1190 | connect(job, SIGNAL(processedSize(KJob *, qulonglong)), this, SLOT(slotProcessedSize(KJob *, qulonglong))); |
| 1191 | connect(job, &KIO::FileCopyJob::result, this, &Synchronizer::slotTaskFinished); |
| 1192 | jobMap[job] = task; |
| 1193 | } else { |
| 1194 | KIO::SimpleJob *job = |
| 1195 | KIO::symlink(task->leftLink(), destURL, ((overWrite || task->overWrite()) ? KIO::Overwrite : KIO::DefaultFlags) | KIO::HideProgressInfo); |