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
92b70a3b
There was an error fetching the commit references. Please try again later.
Commit
92b70a3b
authored
5 years ago
by
Zach Hilman
Browse files
Options
Downloads
Patches
Plain Diff
boxcat: Use Etag header names for file digest
parent
e8183f9e
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/core/file_sys/vfs_libzip.cpp
+10
-14
10 additions, 14 deletions
src/core/file_sys/vfs_libzip.cpp
src/core/hle/service/bcat/backend/boxcat.cpp
+11
-10
11 additions, 10 deletions
src/core/hle/service/bcat/backend/boxcat.cpp
with
21 additions
and
24 deletions
src/core/file_sys/vfs_libzip.cpp
+
10
−
14
View file @
92b70a3b
...
...
@@ -15,25 +15,25 @@ VirtualDir ExtractZIP(VirtualFile file) {
zip_error_t
error
{};
const
auto
data
=
file
->
ReadAllBytes
();
const
auto
src
=
zip_source_buffer_create
(
data
.
data
(),
data
.
size
(),
0
,
&
error
);
std
::
unique_ptr
<
zip_source_t
,
decltype
(
&
zip_source_free
)
>
src
{
zip_source_buffer_create
(
data
.
data
(),
data
.
size
(),
0
,
&
error
),
zip_source_free
};
if
(
src
==
nullptr
)
return
nullptr
;
const
auto
zip
=
zip_open_from_source
(
src
,
0
,
&
error
);
std
::
unique_ptr
<
zip_t
,
decltype
(
&
zip_discard
)
>
zip
{
zip_open_from_source
(
src
.
get
(),
0
,
&
error
),
zip_discard
};
if
(
zip
==
nullptr
)
return
nullptr
;
std
::
shared_ptr
<
VectorVfsDirectory
>
out
=
std
::
make_shared
<
VectorVfsDirectory
>
();
const
auto
num_entries
=
zip_get_num_entries
(
zip
,
0
);
if
(
num_entries
==
-
1
)
return
nullptr
;
const
auto
num_entries
=
zip_get_num_entries
(
zip
.
get
(),
0
);
zip_stat_t
stat
{};
zip_stat_init
(
&
stat
);
for
(
std
::
size_t
i
=
0
;
i
<
num_entries
;
++
i
)
{
const
auto
stat_res
=
zip_stat_index
(
zip
,
i
,
0
,
&
stat
);
const
auto
stat_res
=
zip_stat_index
(
zip
.
get
()
,
i
,
0
,
&
stat
);
if
(
stat_res
==
-
1
)
return
nullptr
;
...
...
@@ -41,15 +41,14 @@ VirtualDir ExtractZIP(VirtualFile file) {
if
(
name
.
empty
())
continue
;
if
(
name
[
name
.
size
()
-
1
]
!=
'/'
)
{
const
auto
file
=
zip_fopen_index
(
zip
,
i
,
0
);
if
(
name
.
back
()
!=
'/'
)
{
std
::
unique_ptr
<
zip_file_t
,
decltype
(
&
zip_fclose
)
>
file
{
zip_fopen_index
(
zip
.
get
(),
i
,
0
),
zip_fclose
};
std
::
vector
<
u8
>
buf
(
stat
.
size
);
if
(
zip_fread
(
file
,
buf
.
data
(),
buf
.
size
())
!=
buf
.
size
())
if
(
zip_fread
(
file
.
get
()
,
buf
.
data
(),
buf
.
size
())
!=
buf
.
size
())
return
nullptr
;
zip_fclose
(
file
);
const
auto
parts
=
FileUtil
::
SplitPathComponents
(
stat
.
name
);
const
auto
new_file
=
std
::
make_shared
<
VectorVfsFile
>
(
buf
,
parts
.
back
());
...
...
@@ -74,9 +73,6 @@ VirtualDir ExtractZIP(VirtualFile file) {
}
}
zip_source_close
(
src
);
zip_close
(
zip
);
return
out
;
}
...
...
This diff is collapsed.
Click to expand it.
src/core/hle/service/bcat/backend/boxcat.cpp
+
11
−
10
View file @
92b70a3b
...
...
@@ -111,18 +111,16 @@ public:
DownloadResult
DownloadDataZip
()
{
return
DownloadInternal
(
fmt
::
format
(
BOXCAT_PATHNAME_DATA
,
title_id
),
TIMEOUT_SECONDS
,
"Boxcat-Data-Digest"
,
"application/zip"
);
"application/zip"
);
}
DownloadResult
DownloadLaunchParam
()
{
return
DownloadInternal
(
fmt
::
format
(
BOXCAT_PATHNAME_LAUNCHPARAM
,
title_id
),
TIMEOUT_SECONDS
/
3
,
"Boxcat-LaunchParam-Digest"
,
"application/octet-stream"
);
TIMEOUT_SECONDS
/
3
,
"application/octet-stream"
);
}
private
:
DownloadResult
DownloadInternal
(
const
std
::
string
&
resolved_path
,
u32
timeout_seconds
,
const
std
::
string
&
digest_header_name
,
const
std
::
string
&
content_type_name
)
{
if
(
client
==
nullptr
)
{
client
=
std
::
make_unique
<
httplib
::
SSLClient
>
(
BOXCAT_HOSTNAME
,
PORT
,
timeout_seconds
);
...
...
@@ -136,10 +134,13 @@ private:
if
(
FileUtil
::
Exists
(
path
))
{
FileUtil
::
IOFile
file
{
path
,
"rb"
};
std
::
vector
<
u8
>
bytes
(
file
.
GetSize
());
file
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
());
const
auto
digest
=
DigestFile
(
bytes
);
headers
.
insert
({
digest_header_name
,
Common
::
HexArrayToString
(
digest
,
false
)});
if
(
file
.
IsOpen
())
{
std
::
vector
<
u8
>
bytes
(
file
.
GetSize
());
file
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
());
const
auto
digest
=
DigestFile
(
bytes
);
headers
.
insert
(
{
std
::
string
(
"If-None-Match"
),
Common
::
HexArrayToString
(
digest
,
false
)});
}
}
const
auto
response
=
client
->
Get
(
resolved_path
.
c_str
(),
headers
);
...
...
@@ -227,7 +228,7 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
FileUtil
::
IOFile
zip
{
zip_path
,
"rb"
};
const
auto
size
=
zip
.
GetSize
();
std
::
vector
<
u8
>
bytes
(
size
);
if
(
size
==
0
||
zip
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
())
!=
bytes
.
size
())
{
if
(
!
zip
.
IsOpen
()
||
size
==
0
||
zip
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
())
!=
bytes
.
size
())
{
LOG_ERROR
(
Service_BCAT
,
"Boxcat failed to read ZIP file at path '{}'!"
,
zip_path
);
failure
();
return
;
...
...
@@ -335,7 +336,7 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title)
FileUtil
::
IOFile
bin
{
path
,
"rb"
};
const
auto
size
=
bin
.
GetSize
();
std
::
vector
<
u8
>
bytes
(
size
);
if
(
size
==
0
||
bin
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
())
!=
bytes
.
size
())
{
if
(
!
bin
.
IsOpen
()
||
size
==
0
||
bin
.
ReadBytes
(
bytes
.
data
(),
bytes
.
size
())
!=
bytes
.
size
())
{
LOG_ERROR
(
Service_BCAT
,
"Boxcat failed to read launch parameter binary at path '{}'!"
,
path
);
return
std
::
nullopt
;
...
...
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