mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 08:39:04 +00:00
Rework failed task cleanup
Now the cleanup of failed tasks (deletion of borked files) is handled by the related task itself, instead of the frontend.
This commit is contained in:
+26
-8
@@ -94,6 +94,15 @@ void SDMCImporter::AbortImporting() {
|
||||
|
||||
bool SDMCImporter::ImportContent(const ContentSpecifier& specifier,
|
||||
const Common::ProgressCallback& callback) {
|
||||
if (!ImportContentImpl(specifier, callback)) {
|
||||
DeleteContent(specifier);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDMCImporter::ImportContentImpl(const ContentSpecifier& specifier,
|
||||
const Common::ProgressCallback& callback) {
|
||||
switch (specifier.type) {
|
||||
case ContentType::Application:
|
||||
case ContentType::Update:
|
||||
@@ -623,8 +632,13 @@ bool SDMCImporter::DumpCXI(const ContentSpecifier& specifier, std::string destin
|
||||
return false;
|
||||
}
|
||||
|
||||
return dump_cxi_ncch->DecryptToFile(std::make_shared<FileUtil::IOFile>(destination, "wb"),
|
||||
callback) == ResultStatus::Success;
|
||||
if (dump_cxi_ncch->DecryptToFile(std::make_shared<FileUtil::IOFile>(destination, "wb"),
|
||||
callback) == ResultStatus::Success) {
|
||||
return true;
|
||||
}
|
||||
|
||||
FileUtil::Delete(destination);
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDMCImporter::AbortDumpCXI() {
|
||||
@@ -675,9 +689,10 @@ bool SDMCImporter::BuildCIA(const ContentSpecifier& specifier, std::string desti
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = cia_builder->Init(destination, tmd, config,
|
||||
FileUtil::GetDirectoryTreeSize(physical_path), callback);
|
||||
const bool ret = cia_builder->Init(destination, tmd, config,
|
||||
FileUtil::GetDirectoryTreeSize(physical_path), callback);
|
||||
if (!ret) {
|
||||
FileUtil::Delete(destination);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -721,11 +736,14 @@ bool SDMCImporter::BuildCIA(const ContentSpecifier& specifier, std::string desti
|
||||
}
|
||||
};
|
||||
|
||||
if (!FileUtil::ForeachDirectoryEntry(nullptr, physical_path, DirectoryEntryCallback)) {
|
||||
return false;
|
||||
if (FileUtil::ForeachDirectoryEntry(nullptr, physical_path, DirectoryEntryCallback) &&
|
||||
cia_builder->Finalize()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return cia_builder->Finalize();
|
||||
FileUtil::Delete(destination);
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDMCImporter::AbortBuildCIA() {
|
||||
@@ -1055,7 +1073,7 @@ void SDMCImporter::ListSysdata(std::vector<ContentSpecifier>& out) const {
|
||||
{ContentType::Sysdata, 2, exists, FileUtil::GetSize(config.seed_db_path), SEED_DB});
|
||||
}
|
||||
|
||||
void SDMCImporter::DeleteContent(const ContentSpecifier& specifier) {
|
||||
void SDMCImporter::DeleteContent(const ContentSpecifier& specifier) const {
|
||||
switch (specifier.type) {
|
||||
case ContentType::Application:
|
||||
case ContentType::Update:
|
||||
|
||||
+6
-7
@@ -112,7 +112,7 @@ public:
|
||||
~SDMCImporter();
|
||||
|
||||
/**
|
||||
* Imports a specific content by its specifier.
|
||||
* Imports a specific content by its specifier, deleting it when failed.
|
||||
* Blocks, but can be aborted on another thread if needed.
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
@@ -151,12 +151,6 @@ public:
|
||||
*/
|
||||
void AbortBuildCIA();
|
||||
|
||||
/**
|
||||
* Deletes/Cleans up a content. Used for deleting contents that have
|
||||
* not been fully imported.
|
||||
*/
|
||||
void DeleteContent(const ContentSpecifier& specifier);
|
||||
|
||||
/**
|
||||
* Gets a list of dumpable content specifiers.
|
||||
*/
|
||||
@@ -170,6 +164,10 @@ public:
|
||||
private:
|
||||
bool Init();
|
||||
|
||||
// Impl of ImportContent without deleting mechanism.
|
||||
bool ImportContentImpl(
|
||||
const ContentSpecifier& specifier,
|
||||
const Common::ProgressCallback& callback = [](std::size_t, std::size_t) {});
|
||||
bool ImportTitle(const ContentSpecifier& specifier, const Common::ProgressCallback& callback);
|
||||
bool ImportNandTitle(const ContentSpecifier& specifier,
|
||||
const Common::ProgressCallback& callback);
|
||||
@@ -187,6 +185,7 @@ private:
|
||||
void ListSystemArchive(std::vector<ContentSpecifier>& out) const;
|
||||
void ListSysdata(std::vector<ContentSpecifier>& out) const;
|
||||
|
||||
void DeleteContent(const ContentSpecifier& specifier) const;
|
||||
void DeleteTitle(u64 id) const;
|
||||
void DeleteNandTitle(u64 id) const;
|
||||
void DeleteSavegame(u64 id) const;
|
||||
|
||||
Reference in New Issue
Block a user