MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / trashInstance

Method trashInstance

launcher/InstanceList.cpp:290–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool 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
318bool InstanceList::trashedSomething() {
319 return !m_trashHistory.empty();

Callers 1

Calls 3

trashFunction · 0.85
instanceRootMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected