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
c62b2392
Commit
c62b2392
authored
Aug 04, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont put check hash in queue
parent
46c72c45
Pipeline
#15368
passed with stages
in 4 minutes and 47 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+35
-35
No files found.
console-api/src/packager/packager.service.ts
View file @
c62b2392
...
@@ -209,9 +209,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -209,9 +209,7 @@ export class PackagerService extends ConsoleLogger {
}
}
async
archive
(
root
:
string
,
archiveTask
:
ArchiveTask
):
Promise
<
Archive
>
{
async
archive
(
root
:
string
,
archiveTask
:
ArchiveTask
):
Promise
<
Archive
>
{
return
this
.
redlock
.
using
([
`archive:
${
archiveTask
.
path
}
`
],
5000
,
async
()
=>
return
this
.
redlock
.
using
([
`archive:
${
archiveTask
.
path
}
`
],
5000
,
async
()
=>
this
.
archiveProcess
(
root
,
archiveTask
));
this
.
archiveQueue
.
add
(()
=>
this
.
archiveProcess
(
root
,
archiveTask
))
);
}
}
private
archiveQueue
=
new
PQueue
({
concurrency
:
parseInt
(
process
.
env
.
PACKAGE_COCURRENCY
)
||
os
.
cpus
().
length
});
private
archiveQueue
=
new
PQueue
({
concurrency
:
parseInt
(
process
.
env
.
PACKAGE_COCURRENCY
)
||
os
.
cpus
().
length
});
...
@@ -229,42 +227,44 @@ export class PackagerService extends ConsoleLogger {
...
@@ -229,42 +227,44 @@ export class PackagerService extends ConsoleLogger {
return
archive
;
return
archive
;
}
}
}
}
const
files
=
archiveTask
.
filePaths
;
return
this
.
archiveQueue
.
add
(
async
()
=>
{
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
archiveTask
.
exactFilePaths
.
length
}
files.`
);
const
files
=
archiveTask
.
filePaths
;
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
archiveTask
.
exactFilePaths
.
length
}
files.`
);
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
--zstd
'
,
'
-cf
'
,
'
-
'
].
concat
(
files
),
{
const
child
=
child_process
.
spawn
(
'
tar
'
,
[
'
--zstd
'
,
'
-cf
'
,
'
-
'
].
concat
(
files
),
{
cwd
:
root
,
cwd
:
root
,
});
const
childPromise
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
child
.
on
(
'
exit
'
,
(
code
)
=>
{
if
(
code
==
0
)
{
resolve
();
}
else
{
reject
(
code
);
}
});
});
child
.
on
(
'
error
'
,
(
error
)
=>
{
const
childPromise
=
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
reject
(
error
);
child
.
on
(
'
exit
'
,
(
code
)
=>
{
if
(
code
==
0
)
{
resolve
();
}
else
{
reject
(
code
);
}
});
child
.
on
(
'
error
'
,
(
error
)
=>
{
reject
(
error
);
});
});
});
});
const
hashObject
=
createHash
(
'
sha256
'
);
const
hashObject
=
createHash
(
'
sha256
'
);
child
.
stdout
.
on
(
'
data
'
,
(
chunk
)
=>
{
child
.
stdout
.
on
(
'
data
'
,
(
chunk
)
=>
{
hashObject
.
update
(
chunk
);
hashObject
.
update
(
chunk
);
});
});
/* if (existing) {
/* if (existing) {
await childPromise;
await childPromise;
archive.hash = hashObject.digest('hex');
archive.hash = hashObject.digest('hex');
return archive;
return archive;
}*/
}*/
const
uploadPromise
=
this
.
s3
.
uploadStream
(
archiveName
,
child
.
stdout
,
{
const
uploadPromise
=
this
.
s3
.
uploadStream
(
archiveName
,
child
.
stdout
,
{
ContentType
:
'
application/tar+zstd
'
,
ContentType
:
'
application/tar+zstd
'
,
});
});
const
[,
{
object
}]
=
await
Promise
.
all
([
childPromise
,
uploadPromise
]);
const
[,
{
object
}]
=
await
Promise
.
all
([
childPromise
,
uploadPromise
]);
archive
.
hash
=
hashObject
.
digest
(
'
hex
'
);
archive
.
hash
=
hashObject
.
digest
(
'
hex
'
);
await
this
.
redis
.
set
(
`hash:
${
archive
.
path
}
`
,
archive
.
hash
,
'
EX
'
,
60
*
60
*
24
);
await
this
.
redis
.
set
(
`hash:
${
archive
.
path
}
`
,
archive
.
hash
,
'
EX
'
,
60
*
60
*
24
);
archive
.
size
=
object
.
Size
;
archive
.
size
=
object
.
Size
;
return
archive
;
return
archive
;
});
}
}
private
spawnAsync
(
command
:
string
,
args
:
string
[],
options
:
child_process
.
SpawnOptions
,
stdinStream
?:
NodeJS
.
ReadableStream
)
{
private
spawnAsync
(
command
:
string
,
args
:
string
[],
options
:
child_process
.
SpawnOptions
,
stdinStream
?:
NodeJS
.
ReadableStream
)
{
...
...
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