mirror of https://github.com/PCSX2/pcsx2.git
Updater: Remove update zip after committing
This commit is contained in:
parent
c3ee97103f
commit
680a3802d7
|
@ -81,15 +81,7 @@ Updater::Updater(ProgressCallback* progress)
|
|||
|
||||
Updater::~Updater()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_archive_opened)
|
||||
SzArEx_Free(&m_archive, &g_Alloc);
|
||||
|
||||
ISzAlloc_Free(&g_Alloc, m_look_stream.buf);
|
||||
|
||||
if (m_file_opened)
|
||||
File_Close(&m_archive_stream.file);
|
||||
#endif
|
||||
CloseUpdateZip();
|
||||
}
|
||||
|
||||
void Updater::SetupLogging(ProgressCallback* progress, const std::string& destination_directory)
|
||||
|
@ -123,6 +115,8 @@ bool Updater::OpenUpdateZip(const char* path)
|
|||
LookToRead2_CreateVTable(&m_look_stream, False);
|
||||
CrcGenerateTable();
|
||||
|
||||
m_zip_path = path;
|
||||
|
||||
m_look_stream.buf = (Byte*)ISzAlloc_Alloc(&g_Alloc, kInputBufSize);
|
||||
if (!m_look_stream.buf)
|
||||
{
|
||||
|
@ -163,6 +157,29 @@ bool Updater::OpenUpdateZip(const char* path)
|
|||
#endif
|
||||
}
|
||||
|
||||
void Updater::CloseUpdateZip()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (m_archive_opened)
|
||||
{
|
||||
SzArEx_Free(&m_archive, &g_Alloc);
|
||||
m_archive_opened = false;
|
||||
}
|
||||
|
||||
if (m_look_stream.buf)
|
||||
{
|
||||
ISzAlloc_Free(&g_Alloc, m_look_stream.buf);
|
||||
m_look_stream.buf = nullptr;
|
||||
}
|
||||
|
||||
if (m_file_opened)
|
||||
{
|
||||
File_Close(&m_archive_stream.file);
|
||||
m_file_opened = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Updater::RecursiveDeleteDirectory(const char* path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -404,3 +421,14 @@ void Updater::CleanupStagingDirectory()
|
|||
if (!RecursiveDeleteDirectory(m_staging_directory.c_str()))
|
||||
m_progress->DisplayFormattedError("Failed to remove staging directory '%s'", m_staging_directory.c_str());
|
||||
}
|
||||
|
||||
void Updater::RemoveUpdateZip()
|
||||
{
|
||||
if (m_zip_path.empty())
|
||||
return;
|
||||
|
||||
CloseUpdateZip();
|
||||
|
||||
if (!FileSystem::DeleteFilePath(m_zip_path.c_str()))
|
||||
m_progress->DisplayFormattedError("Failed to remove update zip '%s'", m_zip_path.c_str());
|
||||
}
|
||||
|
|
|
@ -40,10 +40,13 @@ public:
|
|||
bool StageUpdate();
|
||||
bool CommitUpdate();
|
||||
void CleanupStagingDirectory();
|
||||
void RemoveUpdateZip();
|
||||
|
||||
private:
|
||||
static bool RecursiveDeleteDirectory(const char* path);
|
||||
|
||||
void CloseUpdateZip();
|
||||
|
||||
struct FileToUpdate
|
||||
{
|
||||
u32 file_index;
|
||||
|
@ -52,6 +55,7 @@ private:
|
|||
|
||||
bool ParseZip();
|
||||
|
||||
std::string m_zip_path;
|
||||
std::string m_destination_directory;
|
||||
std::string m_staging_directory;
|
||||
|
||||
|
|
|
@ -385,6 +385,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||
}
|
||||
|
||||
updater.CleanupStagingDirectory();
|
||||
updater.RemoveUpdateZip();
|
||||
|
||||
progress.ModalInformation("Update complete.");
|
||||
|
||||
|
|
Loading…
Reference in New Issue