| 140 | } |
| 141 | |
| 142 | void InstanceCopyTask::copyFinished() |
| 143 | { |
| 144 | auto successful = m_copyFuture.result(); |
| 145 | if (!successful) { |
| 146 | emitFailed(tr("Instance folder copy failed.")); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | // FIXME: shouldn't this be able to report errors? |
| 151 | auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg")); |
| 152 | |
| 153 | InstancePtr inst(new NullInstance(m_globalSettings, instanceSettings, m_stagingPath)); |
| 154 | inst->setName(name()); |
| 155 | inst->setIconKey(m_instIcon); |
| 156 | if (!m_keepPlaytime) { |
| 157 | inst->resetTimePlayed(); |
| 158 | } |
| 159 | if (m_useLinks) { |
| 160 | inst->addLinkedInstanceId(m_origInstance->id()); |
| 161 | auto allowed_symlinks_file = QFileInfo(FS::PathCombine(inst->gameRoot(), "allowed_symlinks.txt")); |
| 162 | |
| 163 | QByteArray allowed_symlinks; |
| 164 | if (allowed_symlinks_file.exists()) { |
| 165 | allowed_symlinks.append(FS::read(allowed_symlinks_file.filePath())); |
| 166 | if (allowed_symlinks.right(1) != "\n") |
| 167 | allowed_symlinks.append("\n"); // we want to be on a new line |
| 168 | } |
| 169 | allowed_symlinks.append(m_origInstance->gameRoot().toUtf8()); |
| 170 | allowed_symlinks.append("\n"); |
| 171 | if (allowed_symlinks_file.isSymLink()) |
| 172 | FS::deletePath( |
| 173 | allowed_symlinks_file |
| 174 | .filePath()); // we dont want to modify the original. also make sure the resulting file is not itself a link. |
| 175 | |
| 176 | try { |
| 177 | FS::write(allowed_symlinks_file.filePath(), allowed_symlinks); |
| 178 | } catch (const FS::FileSystemException& e) { |
| 179 | qCritical() << "Failed to write symlink :" << e.cause(); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | emitSucceeded(); |
| 184 | } |
| 185 | |
| 186 | void InstanceCopyTask::copyAborted() |
| 187 | { |
nothing calls this directly
no test coverage detected