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
8912eb3e
Commit
8912eb3e
authored
Aug 03, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better record update
parent
1e72fbf4
Pipeline
#15310
canceled with stages
in 1 minute and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
17 deletions
+11
-17
console-api/src/app.service.ts
console-api/src/app.service.ts
+10
-14
console-api/src/mirror/mirror.service.ts
console-api/src/mirror/mirror.service.ts
+1
-3
No files found.
console-api/src/app.service.ts
View file @
8912eb3e
...
...
@@ -401,28 +401,24 @@ export class AppService extends ConsoleLogger {
async
migrateHashes
()
{
const
archivesToDo
=
await
this
.
db
.
getRepository
(
Archive
).
find
({
where
:
{
hash
:
IsNull
()
},
select
:
[
'
id
'
,
'
hash
'
,
'
path
'
]
});
const
tmpMap
=
new
Map
<
string
,
string
>
();
const
archivesToSave
:
Archive
[]
=
[];
const
hashMapToUpdate
=
new
Map
<
string
,
string
>
();
for
(
const
archive
of
archivesToDo
)
{
if
(
tmpMap
.
has
(
archive
.
path
))
{
archive
.
hash
=
tmpMap
.
get
(
archive
.
path
);
}
else
{
const
hash
=
await
this
.
getHashForMigrate
(
archive
);
if
(
hash
)
{
archive
.
hash
=
await
this
.
getHashForMigrate
(
archive
);
tmpMap
.
set
(
archive
.
path
,
archive
.
hash
);
archivesToSave
.
push
(
archive
);
}
if
(
hashMapToUpdate
.
has
(
archive
.
path
))
{
continue
;
}
const
hash
=
await
this
.
getHashForMigrate
(
archive
);
if
(
hash
)
{
archive
.
hash
=
await
this
.
getHashForMigrate
(
archive
);
hashMapToUpdate
.
set
(
archive
.
path
,
archive
.
hash
);
}
}
await
this
.
db
.
transaction
(
async
(
edb
)
=>
{
const
repo
=
edb
.
getRepository
(
Archive
);
const
chunks
=
_
.
chunk
(
archivesToSave
,
10000
);
const
chunks
=
_
.
chunk
(
Array
.
from
(
hashMapToUpdate
.
entries
())
,
10000
);
for
(
const
chunk
of
chunks
)
{
await
repo
.
save
(
chunk
);
await
Promise
.
all
(
chunk
.
map
(([
path
,
hash
])
=>
repo
.
update
({
path
},
{
hash
}))
);
}
});
await
this
.
db
.
getRepository
(
Archive
).
save
(
archivesToSave
);
return
new
BlankReturnMessageDto
(
200
,
'
success
'
);
}
...
...
console-api/src/mirror/mirror.service.ts
View file @
8912eb3e
...
...
@@ -57,9 +57,7 @@ export class MirrorService extends ConsoleLogger {
for
(
const
url
of
middlewares
)
{
try
{
this
.
log
(
`Loading middleware
${
url
}
`
);
const
{
data
}
=
await
lastValueFrom
(
this
.
http
.
get
<
ReturnMessage
<
MiddlewareInfo
>>
(
url
,
{
responseType
:
'
json
'
})
);
const
{
data
}
=
await
lastValueFrom
(
this
.
http
.
get
<
ReturnMessage
<
MiddlewareInfo
>>
(
url
,
{
responseType
:
'
json
'
}));
const
middleware
:
Middleware
=
{
url
,
info
:
data
.
data
};
this
.
middlewares
.
push
(
middleware
);
if
(
data
.
data
.
maxSize
)
{
...
...
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