IOS/ES: Implement ImportTitleCancel properly
Mistakenly used the wrong TMD to clean up the import. The original TMD is the one that is supposed to be used when cancelling an import, but I forgot it's in the /import directory after starting an import.
This commit is contained in:
parent
5587342ca1
commit
2058f37596
|
@ -96,6 +96,15 @@ IPCCommandResult ES::ImportTmd(Context& context, const IOCtlVRequest& request)
|
||||||
return GetDefaultReply(ImportTmd(context, tmd));
|
return GetDefaultReply(ImportTmd(context, tmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CleanUpStaleImport(const u64 title_id)
|
||||||
|
{
|
||||||
|
const auto import_tmd = IOS::ES::FindImportTMD(title_id);
|
||||||
|
if (!import_tmd.IsValid())
|
||||||
|
File::DeleteDirRecursively(Common::GetImportTitlePath(title_id) + "/content");
|
||||||
|
else
|
||||||
|
IOS::ES::FinishImport(import_tmd);
|
||||||
|
}
|
||||||
|
|
||||||
ReturnCode ES::ImportTitleInit(Context& context, const std::vector<u8>& tmd_bytes)
|
ReturnCode ES::ImportTitleInit(Context& context, const std::vector<u8>& tmd_bytes)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_ES, "ImportTitleInit");
|
INFO_LOG(IOS_ES, "ImportTitleInit");
|
||||||
|
@ -107,10 +116,7 @@ ReturnCode ES::ImportTitleInit(Context& context, const std::vector<u8>& tmd_byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish a previous import (if it exists).
|
// Finish a previous import (if it exists).
|
||||||
const IOS::ES::TMDReader previous_tmd =
|
CleanUpStaleImport(context.title_import.tmd.GetTitleId());
|
||||||
IOS::ES::FindImportTMD(context.title_import.tmd.GetTitleId());
|
|
||||||
if (previous_tmd.IsValid())
|
|
||||||
FinishImport(previous_tmd);
|
|
||||||
|
|
||||||
if (!IOS::ES::InitImport(context.title_import.tmd.GetTitleId()))
|
if (!IOS::ES::InitImport(context.title_import.tmd.GetTitleId()))
|
||||||
return ES_EIO;
|
return ES_EIO;
|
||||||
|
@ -312,17 +318,7 @@ ReturnCode ES::ImportTitleCancel(Context& context)
|
||||||
if (!context.title_import.tmd.IsValid())
|
if (!context.title_import.tmd.IsValid())
|
||||||
return ES_EINVAL;
|
return ES_EINVAL;
|
||||||
|
|
||||||
const IOS::ES::TMDReader original_tmd =
|
CleanUpStaleImport(context.title_import.tmd.GetTitleId());
|
||||||
IOS::ES::FindInstalledTMD(context.title_import.tmd.GetTitleId());
|
|
||||||
if (!original_tmd.IsValid())
|
|
||||||
{
|
|
||||||
// This should never happen unless someone messed with the installed TMD directly.
|
|
||||||
// Still, let's check for this case and return an error instead of potentially crashing.
|
|
||||||
return FS_ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FinishImport(original_tmd))
|
|
||||||
return ES_EIO;
|
|
||||||
|
|
||||||
INFO_LOG(IOS_ES, "ImportTitleCancel: title %016" PRIx64, context.title_import.tmd.GetTitleId());
|
INFO_LOG(IOS_ES, "ImportTitleCancel: title %016" PRIx64, context.title_import.tmd.GetTitleId());
|
||||||
context.title_import.tmd.SetBytes({});
|
context.title_import.tmd.SetBytes({});
|
||||||
|
|
Loading…
Reference in New Issue