diff --git a/Common/Thread/ThreadManager.cpp b/Common/Thread/ThreadManager.cpp index f1224a64a8..547f13f75f 100644 --- a/Common/Thread/ThreadManager.cpp +++ b/Common/Thread/ThreadManager.cpp @@ -130,10 +130,10 @@ bool ThreadManager::TeardownTask(Task *task, bool enqueue) { static void WorkerThreadFunc(GlobalThreadContext *global, TaskThreadContext *thread) { if (thread->type == TaskType::CPU_COMPUTE) { - snprintf(thread->name, sizeof(thread->name), "PoolWorker %d", thread->index); + snprintf(thread->name, sizeof(thread->name), "PoolW %d", thread->index); } else { _assert_(thread->type == TaskType::IO_BLOCKING); - snprintf(thread->name, sizeof(thread->name), "PoolWorkerIO %d", thread->index); + snprintf(thread->name, sizeof(thread->name), "PoolW IO %d", thread->index); } SetCurrentThreadName(thread->name); diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 292a3eba4a..58b43b747f 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -675,8 +675,8 @@ void __IoInit() { pspFileSystem.Mount("flash0:", flash0System); + const std::string gameId = g_paramSFO.GetDiscID(); if (g_RemasterMode) { - const std::string gameId = g_paramSFO.GetDiscID(); const Path exdataPath = GetSysDirectory(DIRECTORY_EXDATA) / gameId; if (File::Exists(exdataPath)) { auto exdataSystem = std::make_shared(&pspFileSystem, exdataPath, FileSystemFlags::SIMULATE_FAT32 | FileSystemFlags::CARD); @@ -698,7 +698,7 @@ void __IoInit() { __KernelRegisterWaitTypeFuncs(WAITTYPE_ASYNCIO, __IoAsyncBeginCallback, __IoAsyncEndCallback); - MemoryStick_Init(); + MemoryStick_Init(gameId); lastMemStickState = MemoryStick_State(); lastMemStickFatState = MemoryStick_FatState(); __DisplayListenVblank(__IoVblank); diff --git a/Core/HW/MemoryStick.cpp b/Core/HW/MemoryStick.cpp index 000e067289..fcfbc5b642 100644 --- a/Core/HW/MemoryStick.cpp +++ b/Core/HW/MemoryStick.cpp @@ -23,6 +23,8 @@ #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" #include "Common/Thread/ThreadUtil.h" +#include "Common/File/DiskFree.h" +#include "Common/File/FileUtil.h" #include "Core/Config.h" #include "Core/CoreTiming.h" #include "Core/Compatibility.h" @@ -158,7 +160,7 @@ void MemoryStick_SetState(MemStickState state) { } } -void MemoryStick_Init() { +void MemoryStick_Init(std::string gameID) { if (g_Config.bMemStickInserted) { memStickState = PSP_MEMORYSTICK_STATE_INSERTED; memStickFatState = PSP_FAT_MEMORYSTICK_STATE_ASSIGNED; @@ -170,10 +172,19 @@ void MemoryStick_Init() { memStickNeedsAssign = false; const CompatFlags &flags = PSP_CoreParameter().compat.flags(); + //if (flags.MemstickFixedFree) { + // See issue #12761 - g_initialMemstickSizePromise = Promise::Spawn(&g_threadManager, []() -> uint64_t { - INFO_LOG(Log::System, "Calculating initial savedata size..."); - return pspFileSystem.FreeDiskSpace("ms0:/") + pspFileSystem.ComputeRecursiveDirectorySize("ms0:/PSP/SAVEDATA/"); + g_initialMemstickSizePromise = Promise::Spawn(&g_threadManager, [gameID]() -> uint64_t { + INFO_LOG(Log::System, "Calculating initial savedata size for %s...", gameID.c_str()); + // NOTE: We only really need to sum up the diskspace for subfolders related to this game, and add it to the actual free space, + // to obtain the free space with the save data removed. + // We previously went through the meta file system here, but the memstick is always a directory so no need. + Path saveFolder = GetSysDirectory(DIRECTORY_SAVEDATA); + int64_t freeSpace = 0; + free_disk_space(saveFolder, freeSpace); + freeSpace += File::ComputeRecursiveDirectorySize(saveFolder); + return freeSpace; }, TaskType::IO_BLOCKING); } diff --git a/Core/HW/MemoryStick.h b/Core/HW/MemoryStick.h index 00ecfefba2..48b21e445d 100644 --- a/Core/HW/MemoryStick.h +++ b/Core/HW/MemoryStick.h @@ -17,6 +17,8 @@ #pragma once +#include + #include "Common/CommonTypes.h" class PointerWrap; @@ -40,7 +42,7 @@ enum MemStickDriverState { PSP_MEMORYSTICK_STATE_DEVICE_REMOVED = 8, }; -void MemoryStick_Init(); +void MemoryStick_Init(std::string gameID); void MemoryStick_Shutdown(); void MemoryStick_DoState(PointerWrap &p); MemStickState MemoryStick_State();