Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
46e2ca54
There was an error fetching the commit references. Please try again later.
Commit
46e2ca54
authored
5 years ago
by
Zach Hilman
Browse files
Options
Downloads
Patches
Plain Diff
game_list_worker: Add better error handling to caching
parent
944c07ac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/yuzu/configuration/config.cpp
+3
-2
3 additions, 2 deletions
src/yuzu/configuration/config.cpp
src/yuzu/game_list_worker.cpp
+39
-21
39 additions, 21 deletions
src/yuzu/game_list_worker.cpp
with
42 additions
and
23 deletions
src/yuzu/configuration/config.cpp
+
3
−
2
View file @
46e2ca54
...
...
@@ -645,7 +645,8 @@ void Config::ReadUIGamelistValues() {
UISettings
::
values
.
icon_size
=
ReadSetting
(
QStringLiteral
(
"icon_size"
),
64
).
toUInt
();
UISettings
::
values
.
row_1_text_id
=
ReadSetting
(
QStringLiteral
(
"row_1_text_id"
),
3
).
toUInt
();
UISettings
::
values
.
row_2_text_id
=
ReadSetting
(
QStringLiteral
(
"row_2_text_id"
),
2
).
toUInt
();
UISettings
::
values
.
cache_game_list
=
ReadSetting
(
QStringLiteral
(
"cache_game_list"
),
true
).
toBool
();
UISettings
::
values
.
cache_game_list
=
ReadSetting
(
QStringLiteral
(
"cache_game_list"
),
true
).
toBool
();
qt_config
->
endGroup
();
}
...
...
@@ -1010,7 +1011,7 @@ void Config::SaveUIGamelistValues() {
WriteSetting
(
QStringLiteral
(
"icon_size"
),
UISettings
::
values
.
icon_size
,
64
);
WriteSetting
(
QStringLiteral
(
"row_1_text_id"
),
UISettings
::
values
.
row_1_text_id
,
3
);
WriteSetting
(
QStringLiteral
(
"row_2_text_id"
),
UISettings
::
values
.
row_2_text_id
,
2
);
WriteSetting
(
QStringLiteral
(
"cache_game_list"
),
UISettings
::
values
.
cache_game_list
,
true
);
WriteSetting
(
QStringLiteral
(
"cache_game_list"
),
UISettings
::
values
.
cache_game_list
,
true
);
qt_config
->
endGroup
();
}
...
...
This diff is collapsed.
Click to expand it.
src/yuzu/game_list_worker.cpp
+
39
−
21
View file @
46e2ca54
...
...
@@ -39,11 +39,12 @@ T GetGameListCachedObject(const std::string& filename, const std::string& ext,
template
<
>
QString
GetGameListCachedObject
(
const
std
::
string
&
filename
,
const
std
::
string
&
ext
,
const
std
::
function
<
QString
()
>&
generator
)
{
if
(
!
UISettings
::
values
.
cache_game_list
||
filename
==
"0000000000000000"
)
if
(
!
UISettings
::
values
.
cache_game_list
||
filename
==
"0000000000000000"
)
{
return
generator
();
}
const
auto
&
path
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
"."
+
ext
;
const
auto
path
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
'.'
+
ext
;
FileUtil
::
CreateFullPath
(
path
);
...
...
@@ -51,10 +52,10 @@ QString GetGameListCachedObject(const std::string& filename, const std::string&
const
auto
str
=
generator
();
std
::
ofstream
stream
(
path
);
if
(
stream
)
if
(
stream
)
{
stream
<<
str
.
toStdString
();
}
stream
.
close
();
return
str
;
}
...
...
@@ -63,7 +64,6 @@ QString GetGameListCachedObject(const std::string& filename, const std::string&
if
(
stream
)
{
const
std
::
string
out
(
std
::
istreambuf_iterator
<
char
>
{
stream
},
std
::
istreambuf_iterator
<
char
>
{});
stream
.
close
();
return
QString
::
fromStdString
(
out
);
}
...
...
@@ -74,13 +74,14 @@ template <>
std
::
pair
<
std
::
vector
<
u8
>
,
std
::
string
>
GetGameListCachedObject
(
const
std
::
string
&
filename
,
const
std
::
string
&
ext
,
const
std
::
function
<
std
::
pair
<
std
::
vector
<
u8
>
,
std
::
string
>
()
>&
generator
)
{
if
(
!
UISettings
::
values
.
cache_game_list
||
filename
==
"0000000000000000"
)
if
(
!
UISettings
::
values
.
cache_game_list
||
filename
==
"0000000000000000"
)
{
return
generator
();
}
const
auto
&
path1
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
".jpeg"
;
const
auto
&
path2
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
".appname.txt"
;
const
auto
path1
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
".jpeg"
;
const
auto
path2
=
FileUtil
::
GetUserPath
(
FileUtil
::
UserPath
::
CacheDir
)
+
DIR_SEP
+
"game_list"
+
DIR_SEP
+
filename
+
".appname.txt"
;
FileUtil
::
CreateFullPath
(
path1
);
...
...
@@ -88,28 +89,48 @@ std::pair<std::vector<u8>, std::string> GetGameListCachedObject(
const
auto
[
icon
,
nacp
]
=
generator
();
FileUtil
::
IOFile
file1
(
path1
,
"wb"
);
file1
.
Resize
(
icon
.
size
());
file1
.
WriteBytes
(
icon
.
data
(),
icon
.
size
());
if
(
!
file1
.
IsOpen
())
{
LOG_ERROR
(
Frontend
,
"Failed to open cache file."
);
return
generator
();
}
if
(
!
file1
.
Resize
(
icon
.
size
()))
{
LOG_ERROR
(
Frontend
,
"Failed to resize cache file to necessary size."
);
return
generator
();
}
if
(
file1
.
WriteBytes
(
icon
.
data
(),
icon
.
size
())
!=
icon
.
size
())
{
LOG_ERROR
(
Frontend
,
"Failed to write data to cache file."
);
return
generator
();
}
std
::
ofstream
stream2
(
path2
,
std
::
ios
::
out
);
if
(
stream2
)
if
(
stream2
)
{
stream2
<<
nacp
;
}
file1
.
Close
();
stream2
.
close
();
return
std
::
make_pair
(
icon
,
nacp
);
}
FileUtil
::
IOFile
file1
(
path1
,
"rb"
);
std
::
ifstream
stream2
(
path2
);
if
(
!
file1
.
IsOpen
())
{
LOG_ERROR
(
Frontend
,
"Failed to open cache file for reading."
);
return
generator
();
}
if
(
!
stream2
)
{
LOG_ERROR
(
Frontend
,
"Failed to open cache file for reading."
);
return
generator
();
}
std
::
vector
<
u8
>
vec
(
file1
.
GetSize
());
file1
.
ReadBytes
(
vec
.
data
(),
vec
.
size
());
if
(
stream2
&&
!
vec
.
empty
())
{
const
std
::
string
out
(
std
::
istreambuf_iterator
<
char
>
{
stream2
},
std
::
istreambuf_iterator
<
char
>
{});
stream2
.
close
();
return
std
::
make_pair
(
vec
,
out
);
}
...
...
@@ -118,14 +139,11 @@ std::pair<std::vector<u8>, std::string> GetGameListCachedObject(
void
GetMetadataFromControlNCA
(
const
FileSys
::
PatchManager
&
patch_manager
,
const
FileSys
::
NCA
&
nca
,
std
::
vector
<
u8
>&
icon
,
std
::
string
&
name
)
{
auto
res
=
GetGameListCachedObject
<
std
::
pair
<
std
::
vector
<
u8
>
,
std
::
string
>>
(
std
::
tie
(
icon
,
name
)
=
GetGameListCachedObject
<
std
::
pair
<
std
::
vector
<
u8
>
,
std
::
string
>>
(
fmt
::
format
(
"{:016X}"
,
patch_manager
.
GetTitleID
()),
{},
[
&
patch_manager
,
&
nca
]
{
const
auto
[
nacp
,
icon_f
]
=
patch_manager
.
ParseControlNCA
(
nca
);
return
std
::
make_pair
(
icon_f
->
ReadAllBytes
(),
nacp
->
GetApplicationName
());
});
icon
=
std
::
move
(
res
.
first
);
name
=
std
::
move
(
res
.
second
);
}
bool
HasSupportedFileExtension
(
const
std
::
string
&
file_name
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment