Skip to content
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

Merged
merged 12 commits into from Apr 18, 2018
Merged

Implemented sysCacheClear() #4445

merged 12 commits into from Apr 18, 2018

Conversation

TheAnig
Copy link
Contributor

@TheAnig TheAnig commented Apr 14, 2018

Implemented sysCacheClear() so that games like Folklore that rely on it don't get stuck on a black screen. Refer to this issue.

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))) {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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))) {
Copy link
Member

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.

Copy link
Contributor Author

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.

@VelocityRa
Copy link
Member

Actually this appears to be incorrect, the function receives no arguments:

image

As you can see here, r3 is immediately overwritten with the value 1, discarding any arguments that could have been passed.

The CellSysCacheParam is most likely used with the function cellSysCacheMount instead.

@VelocityRa
Copy link
Member

Did you actually test it? What is passed as the argument?

@TheAnig
Copy link
Contributor Author

TheAnig commented Apr 14, 2018

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)

@money123451
Copy link

this PR regresses echochrome NPUA80134 logs
PR
Master

@VelocityRa
Copy link
Member

As I said, it's wrong, don't test, yet

@VelocityRa
Copy link
Member

@TheAnig In case it wasn't clear: you are supposed to use fxm::get to get the parameters, instead of the argument.

{
cellSysutil.todo("cellSysCacheClear()");
// Checks if the param exists, else we quit

if (!fxm::check<CellSysCacheParam>())
Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor Author

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

@TheAnig
Copy link
Contributor Author

TheAnig commented Apr 15, 2018

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;
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Member

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

@IllusionMan1212
Copy link

PR works as intended, no noticeable regressions.

return CELL_SYSCACHE_ERROR_ACCESS_ERROR;
}

const std::string& cache_id = param->cacheId;
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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.

@TheAnig
Copy link
Contributor Author

TheAnig commented Apr 17, 2018

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()");
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

@Nekotekina Nekotekina merged commit eb3dfb6 into RPCS3:master Apr 18, 2018
@Rpcs3tester
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants