New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented sysCacheClear() #4445
Conversation
const std::string& cache_id = param->cacheId; | ||
const std::string& cache_path = "/dev_hdd1/cache/" + cache_id + '/'; | ||
|
||
if (!fs::exists(vfs::get(cache_path)) || !fs::is_dir(vfs::get(cache_path))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use {
in a new line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also you might as well use the vfs::get earlier when initializing cache_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I'll fix this and post another.
const std::string& cache_id = param->cacheId; | ||
const std::string& cache_path = "/dev_hdd1/cache/" + cache_id + '/'; | ||
|
||
if (!fs::exists(vfs::get(cache_path)) || !fs::is_dir(vfs::get(cache_path))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more of a nit, but you're calling vfs::get
on the same path thrice, could make that a separate local.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this also along with the changes Megamouse proposed.
Did you actually test it? What is passed as the argument? |
I tested a wrong version. I'm working on a fix. (Also I needed game_id subfolder to clear which is what I assumed was the argument) |
As I said, it's wrong, don't test, yet |
@TheAnig In case it wasn't clear: you are supposed to use |
{ | ||
cellSysutil.todo("cellSysCacheClear()"); | ||
// Checks if the param exists, else we quit | ||
|
||
if (!fxm::check<CellSysCacheParam>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I told you on Discord, remove this and add it below if fxm::get
fails
|
||
// TODO: Write tests to figure out, what is deleted. | ||
fs::remove_dir(dir_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're supposed to use fs::remove_all(dir_path, true)
for it to be recursive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I'll fix it
Finally, everything seems fixed. I'll wait for a proper review though, but my intention of fixing Issue #4272 seems to has been realized. |
// Get the param as a shared ptr, then decipher the cacheid from it | ||
// (Instead of assuming naively that the param is passed as argument) | ||
std::shared_ptr<CellSysCacheParam> param = fxm::get<CellSysCacheParam>(); | ||
const std::string& cache_id = param->cacheId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still need to check for
if (!param) return CELL_SYSCACHE_ERROR_ACCESS_ERROR;
or something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do that check above in
if(!fxm::check<CellSysCacheParam>())
and return CELL_SYSCACHE_ERROR_NOTMOUNTED
This check was already part of the repo beforehand so I didn't change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I told you to...
Also - you can change existing code you know :p
PR works as intended, no noticeable regressions. |
return CELL_SYSCACHE_ERROR_ACCESS_ERROR; | ||
} | ||
|
||
const std::string& cache_id = param->cacheId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't bind references, it's old style.
|
||
// TODO: Write tests to figure out, what is deleted. | ||
// Unit test for param ptr, since it may be null at the time of get() | ||
if (!param) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty much NOTMOUNTED error, fxm::check becomes unnecessary.
{ | ||
cellSysutil.todo("cellSysCacheClear()"); | ||
// Checks if the param exists, else we quit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log command shouldn't be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I'll push a new version tonight after I get back from work.
Added the requested changes. Everything seems to work. |
// Get the param as a shared ptr, then decipher the cacheid from it | ||
// (Instead of assuming naively that the param is passed as argument) | ||
std::shared_ptr<CellSysCacheParam> param = fxm::get<CellSysCacheParam>(); | ||
|
||
cellSysutil.todo("cellSysCacheClear()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use warning
log type instead of todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also.. put it in the beginning of the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
i think this fix black screen after delete game shader cache .. before it get stuck you need to Reopen RPCS3 to get next screen . tested twice on Heavenly sowrd |
Implemented sysCacheClear() so that games like Folklore that rely on it don't get stuck on a black screen. Refer to this issue.