| 288 | } |
| 289 | |
| 290 | bool InstanceList::trashInstance(const InstanceId& id) |
| 291 | { |
| 292 | auto inst = getInstanceById(id); |
| 293 | if (!inst) { |
| 294 | qDebug() << "Cannot trash instance" << id << ". No such instance is present (deleted externally?)."; |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | auto cachedGroupId = m_instanceGroupIndex[id]; |
| 299 | |
| 300 | qDebug() << "Will trash instance" << id; |
| 301 | QString trashedLoc; |
| 302 | |
| 303 | if (m_instanceGroupIndex.remove(id)) { |
| 304 | saveGroupList(); |
| 305 | } |
| 306 | |
| 307 | if (!FS::trash(inst->instanceRoot(), &trashedLoc)) { |
| 308 | qDebug() << "Trash of instance" << id << "has not been completely successfully..."; |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | qDebug() << "Instance" << id << "has been trashed by the launcher."; |
| 313 | m_trashHistory.push({id, inst->instanceRoot(), trashedLoc, cachedGroupId}); |
| 314 | |
| 315 | return true; |
| 316 | } |
| 317 | |
| 318 | bool InstanceList::trashedSomething() { |
| 319 | return !m_trashHistory.empty(); |
no test coverage detected