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
efe8a3ad
Commit
efe8a3ad
authored
Oct 26, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit mirror concurrent
parent
7e1abb5c
Pipeline
#17471
passed with stages
in 1 minute and 55 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
console-api/src/mirror/mirror.service.ts
console-api/src/mirror/mirror.service.ts
+7
-11
No files found.
console-api/src/mirror/mirror.service.ts
View file @
efe8a3ad
...
@@ -38,6 +38,7 @@ export interface UploadResult {
...
@@ -38,6 +38,7 @@ export interface UploadResult {
export
class
MirrorService
extends
ConsoleLogger
{
export
class
MirrorService
extends
ConsoleLogger
{
private
middlewares
=
new
Map
<
string
,
Middleware
>
();
private
middlewares
=
new
Map
<
string
,
Middleware
>
();
private
maximumMirroredSize
=
0x7fffffff
;
private
maximumMirroredSize
=
0x7fffffff
;
private
mirrorConcurrent
=
this
.
config
.
get
(
'
MIRROR_CONCURRENT
'
)
||
100
;
constructor
(
constructor
(
@
InjectConnection
(
'
app
'
)
@
InjectConnection
(
'
app
'
)
private
db
:
Connection
,
private
db
:
Connection
,
...
@@ -133,10 +134,11 @@ export class MirrorService extends ConsoleLogger {
...
@@ -133,10 +134,11 @@ export class MirrorService extends ConsoleLogger {
.
distinctOn
([
'
archive.path
'
])
.
distinctOn
([
'
archive.path
'
])
.
from
(
Archive
,
'
archive
'
)
.
from
(
Archive
,
'
archive
'
)
.
where
(
'
archive.size <= :maximumMirroredSize
'
,
{
maximumMirroredSize
:
this
.
maximumMirroredSize
});
.
where
(
'
archive.size <= :maximumMirroredSize
'
,
{
maximumMirroredSize
:
this
.
maximumMirroredSize
});
query
.
andWhere
(
query
`not exists
${
query
.
subQuery
().
select
(
'
mirror.path
'
).
from
(
ArchiveMirror
,
'
mirror
'
).
where
(
'
archive.path = mirror.path
'
).
getQuery
()}
`
.
andWhere
(
);
`not exists
${
query
.
subQuery
().
select
(
'
mirror.path
'
).
from
(
ArchiveMirror
,
'
mirror
'
).
where
(
'
archive.path = mirror.path
'
).
getQuery
()}
`
//.take(100);
)
.
take
(
this
.
mirrorConcurrent
);
this
.
log
(
`Searching for archives to mirror`
);
this
.
log
(
`Searching for archives to mirror`
);
const
archives
=
await
query
.
getMany
();
const
archives
=
await
query
.
getMany
();
if
(
!
archives
.
length
)
{
if
(
!
archives
.
length
)
{
...
@@ -149,13 +151,7 @@ export class MirrorService extends ConsoleLogger {
...
@@ -149,13 +151,7 @@ export class MirrorService extends ConsoleLogger {
return
false
;
return
false
;
}
}
this
.
log
(
`Saving
${
uploadResults
.
length
}
mirror records.`
);
this
.
log
(
`Saving
${
uploadResults
.
length
}
mirror records.`
);
await
this
.
db
.
transaction
(
async
(
edb
)
=>
{
await
this
.
db
.
getRepository
(
ArchiveMirror
).
save
(
uploadResults
);
const
entTrunks
=
_
.
chunk
(
uploadResults
,
20000
);
for
(
const
chunk
of
entTrunks
)
{
await
edb
.
getRepository
(
ArchiveMirror
).
save
(
chunk
);
}
});
return
true
;
}
}
private
async
uploadWithMiddlewareProcess
(
uploadInfo
:
UploadInfo
,
middleware
:
Middleware
):
Promise
<
UploadResult
>
{
private
async
uploadWithMiddlewareProcess
(
uploadInfo
:
UploadInfo
,
middleware
:
Middleware
):
Promise
<
UploadResult
>
{
...
...
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