Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
d9138762
Commit
d9138762
authored
Jul 14, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix too many files things
parent
0a0e2621
Pipeline
#39002
passed with stages
in 5 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
4 deletions
+61
-4
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+61
-4
No files found.
console-api/src/packager/packager.service.ts
View file @
d9138762
...
@@ -23,6 +23,8 @@ interface FileWithHash {
...
@@ -23,6 +23,8 @@ interface FileWithHash {
hash
:
string
;
hash
:
string
;
}
}
const
ARG_SIZE_LIMIT
=
30000
;
class
ArchiveTask
{
class
ArchiveTask
{
readonly
path
:
string
;
readonly
path
:
string
;
constructor
(
public
readonly
role
:
ArchiveType
,
public
readonly
files
:
FileWithHash
[],
public
readonly
altFiles
?:
string
[])
{
constructor
(
public
readonly
role
:
ArchiveType
,
public
readonly
files
:
FileWithHash
[],
public
readonly
altFiles
?:
string
[])
{
...
@@ -200,11 +202,52 @@ export class PackagerService extends ConsoleLogger {
...
@@ -200,11 +202,52 @@ export class PackagerService extends ConsoleLogger {
}
}
async
checksum
(
root
:
string
,
directories
:
string
[],
files
:
string
[]):
Promise
<
Record
<
string
,
string
>>
{
async
checksum
(
root
:
string
,
directories
:
string
[],
files
:
string
[]):
Promise
<
Record
<
string
,
string
>>
{
const
{
stdout
}
=
await
util
.
promisify
(
child_process
.
execFile
)(
'
sha256sum
'
,
files
,
{
maxBuffer
:
1
*
1024
**
3
,
cwd
:
root
});
// 通常系统参数限制在 128KB 左右,保守一点设为 32KB
function
chunkFiles
(
files
:
string
[],
limit
=
ARG_SIZE_LIMIT
):
string
[][]
{
const
chunks
:
string
[][]
=
[];
let
currentChunk
:
string
[]
=
[];
let
currentSize
=
0
;
for
(
const
file
of
files
)
{
const
size
=
Buffer
.
byteLength
(
file
)
+
1
;
// +1 for space
if
(
currentSize
+
size
>
limit
&&
currentChunk
.
length
>
0
)
{
chunks
.
push
(
currentChunk
);
currentChunk
=
[];
currentSize
=
0
;
}
currentChunk
.
push
(
file
);
currentSize
+=
size
;
}
if
(
currentChunk
.
length
>
0
)
{
chunks
.
push
(
currentChunk
);
}
return
chunks
;
}
const
fileChunks
=
chunkFiles
(
files
);
const
chunkPromises
=
fileChunks
.
map
((
chunk
)
=>
util
.
promisify
(
child_process
.
execFile
)(
'
sha256sum
'
,
chunk
,
{
cwd
:
root
,
maxBuffer
:
1
*
1024
**
3
,
}).
then
(({
stdout
})
=>
stdout
.
trim
()
.
split
(
'
\n
'
)
.
map
((
line
)
=>
line
.
split
(
'
'
,
2
).
reverse
())
)
);
const
results
=
(
await
Promise
.
all
(
chunkPromises
)).
flat
();
return
Object
.
fromEntries
([
return
Object
.
fromEntries
([
[
'
.
'
,
''
],
[
'
.
'
,
''
],
...
directories
.
map
((
d
)
=>
[
d
,
''
]),
...
directories
.
map
((
d
)
=>
[
d
,
''
]),
...
stdout
.
split
(
'
\n
'
).
map
((
line
)
=>
line
.
split
(
'
'
,
2
).
reverse
())
,
...
results
,
]);
]);
}
}
...
@@ -245,8 +288,23 @@ export class PackagerService extends ConsoleLogger {
...
@@ -245,8 +288,23 @@ export class PackagerService extends ConsoleLogger {
return
this
.
archiveQueue
.
add
(
async
()
=>
{
return
this
.
archiveQueue
.
add
(
async
()
=>
{
const
files
=
archiveTask
.
filePaths
;
const
files
=
archiveTask
.
filePaths
;
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
archiveTask
.
exactFilePaths
.
length
}
files.`
);
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
archiveTask
.
exactFilePaths
.
length
}
files.`
);
let
tmpFilename
:
string
;
let
fileParams
=
files
;
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
--zstd
'
,
'
-cf
'
,
'
-
'
].
concat
(
files
),
{
const
shouldUseFileList
=
(
files
:
string
[],
limit
=
ARG_SIZE_LIMIT
):
boolean
=>
{
const
totalLength
=
files
.
reduce
((
sum
,
f
)
=>
sum
+
Buffer
.
byteLength
(
f
)
+
1
,
0
);
// +1 for space/newline
return
totalLength
>
limit
;
};
if
(
shouldUseFileList
(
files
))
{
this
.
warn
(
`Too many files in archive
${
archiveName
}
, using file list.`
);
tmpFilename
=
path
.
join
(
this
.
packagerWorkingDirectory
,
`filelist-
${
archiveName
}
.txt`
);
await
fs
.
promises
.
writeFile
(
tmpFilename
,
files
.
join
(
'
\n
'
),
'
utf8
'
);
fileParams
=
[
'
--files-from
'
,
tmpFilename
];
}
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
--zstd
'
,
'
-cf
'
,
'
-
'
,
...
fileParams
],
{
cwd
:
root
,
cwd
:
root
,
});
});
const
childPromise
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
const
childPromise
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
...
@@ -270,7 +328,6 @@ export class PackagerService extends ConsoleLogger {
...
@@ -270,7 +328,6 @@ export class PackagerService extends ConsoleLogger {
});
});
let
uploadStream
=
child
.
stdout
;
let
uploadStream
=
child
.
stdout
;
let
tmpFilename
:
string
;
try
{
try
{
/* if (files.length > 1000) {
/* if (files.length > 1000) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment