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
c1fdf5ca
Commit
c1fdf5ca
authored
Jul 23, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fulls
parent
6158e200
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
29 deletions
+31
-29
console-api/src/entities/Archive.entity.ts
console-api/src/entities/Archive.entity.ts
+1
-0
console-api/src/update/update.service.ts
console-api/src/update/update.service.ts
+30
-29
No files found.
console-api/src/entities/Archive.entity.ts
View file @
c1fdf5ca
...
@@ -8,6 +8,7 @@ export enum ArchiveType {
...
@@ -8,6 +8,7 @@ export enum ArchiveType {
Full
=
'
full
'
,
Full
=
'
full
'
,
Update
=
'
update
'
,
Update
=
'
update
'
,
Part
=
'
part
'
,
Part
=
'
part
'
,
Fulls
=
'
fulls
'
,
}
}
@
Entity
()
@
Entity
()
...
...
console-api/src/update/update.service.ts
View file @
c1fdf5ca
...
@@ -10,8 +10,8 @@ import { PackageS3Service } from '../package-s3/package-s3.service';
...
@@ -10,8 +10,8 @@ import { PackageS3Service } from '../package-s3/package-s3.service';
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
{
AppsJson
}
from
'
../utility/apps-json-type
'
;
import
{
AppsJson
}
from
'
../utility/apps-json-type
'
;
import
{
MirrorService
}
from
'
../mirror/mirror.service
'
;
import
{
MirrorService
}
from
'
../mirror/mirror.service
'
;
import
Platform
=
AppsJson
.
Platform
;
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
import
Platform
=
AppsJson
.
Platform
;
@
Injectable
()
@
Injectable
()
export
class
UpdateService
extends
ConsoleLogger
{
export
class
UpdateService
extends
ConsoleLogger
{
...
@@ -159,9 +159,14 @@ export class UpdateService extends ConsoleLogger {
...
@@ -159,9 +159,14 @@ export class UpdateService extends ConsoleLogger {
}
}
async
getFullPackageMetalink
(
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
,
ip
:
string
)
{
async
getFullPackageMetalink
(
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
,
ip
:
string
)
{
const
archives
=
await
this
.
getArchives
(
id
,
depotDto
,
version
,
(
qb
)
=>
const
tryRole
=
(
role
:
ArchiveType
)
=>
qb
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
]).
andWhere
(
'
archive.role = :fullRole
'
,
{
fullRole
:
ArchiveType
.
Full
})
this
.
getArchives
(
id
,
depotDto
,
version
,
(
qb
)
=>
);
qb
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
]).
andWhere
(
'
archive.role = :fullRole
'
,
{
fullRole
:
ArchiveType
.
Full
})
);
let
archives
=
await
tryRole
(
ArchiveType
.
Fulls
);
if
(
!
archives
.
length
)
{
archives
=
await
tryRole
(
ArchiveType
.
Full
);
}
await
this
.
mirror
.
lookForArchivesMirror
(
archives
,
ip
);
await
this
.
mirror
.
lookForArchivesMirror
(
archives
,
ip
);
archives
.
forEach
((
a
)
=>
a
.
fillUrl
(
this
.
cdnUrl
,
this
.
cdnUrlOversize
));
archives
.
forEach
((
a
)
=>
a
.
fillUrl
(
this
.
cdnUrl
,
this
.
cdnUrlOversize
));
return
{
return
{
...
@@ -231,13 +236,16 @@ export class UpdateService extends ConsoleLogger {
...
@@ -231,13 +236,16 @@ export class UpdateService extends ConsoleLogger {
}
}
const
requestedFilesSet
=
new
Set
(
requestedFiles
);
const
requestedFilesSet
=
new
Set
(
requestedFiles
);
const
build
=
await
this
.
getBuild
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
select
(
'
build.id
'
));
const
build
=
await
this
.
getBuild
(
id
,
depotDto
,
version
,
(
qb
)
=>
qb
.
select
(
'
build.id
'
));
const
updateArchives
=
await
this
.
db
const
getArchiveQuery
=
(
role
:
ArchiveType
)
=>
.
getRepository
(
Archive
)
this
.
db
.
createQueryBuilder
(
'
archive
'
)
.
getRepository
(
Archive
)
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
,
'
archive.files
'
])
.
createQueryBuilder
(
'
archive
'
)
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
,
'
archive.files
'
])
.
andWhere
(
'
archive.role = :updateRole
'
,
{
updateRole
:
ArchiveType
.
Update
})
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
getMany
();
.
andWhere
(
'
archive.role = :role
'
,
{
role
});
const
getArchives
=
(
role
:
ArchiveType
)
=>
getArchiveQuery
(
role
).
getMany
();
const
getSingleArchive
=
(
role
:
ArchiveType
)
=>
getArchiveQuery
(
role
).
limit
(
1
).
getOneOrFail
();
const
updateArchives
=
await
getArchives
(
ArchiveType
.
Update
);
const
suitableUpdateArchives
=
updateArchives
.
filter
((
a
)
=>
a
.
files
.
every
((
f
)
=>
requestedFilesSet
.
has
(
f
)));
const
suitableUpdateArchives
=
updateArchives
.
filter
((
a
)
=>
a
.
files
.
every
((
f
)
=>
requestedFilesSet
.
has
(
f
)));
let
bestUpdateArchive
:
Archive
;
let
bestUpdateArchive
:
Archive
;
if
(
suitableUpdateArchives
.
length
)
{
if
(
suitableUpdateArchives
.
length
)
{
...
@@ -251,7 +259,7 @@ export class UpdateService extends ConsoleLogger {
...
@@ -251,7 +259,7 @@ export class UpdateService extends ConsoleLogger {
remainingFiles
=
requestedFiles
.
filter
((
f
)
=>
!
exactFiles
.
has
(
f
));
remainingFiles
=
requestedFiles
.
filter
((
f
)
=>
!
exactFiles
.
has
(
f
));
// If single update archive satisfies all requested files, return it.
// If single update archive satisfies all requested files, return it.
if
(
!
remainingFiles
.
length
)
{
if
(
!
remainingFiles
.
length
)
{
// console.log('exact', bestUpdateArchive);
// console.log('exact', bestUpdateArchive);
updateArchives
await
this
.
mirror
.
lookForArchivesMirror
([
bestUpdateArchive
],
ip
);
await
this
.
mirror
.
lookForArchivesMirror
([
bestUpdateArchive
],
ip
);
bestUpdateArchive
.
fillUrl
(
this
.
cdnUrl
,
this
.
cdnUrlOversize
);
bestUpdateArchive
.
fillUrl
(
this
.
cdnUrl
,
this
.
cdnUrlOversize
);
return
{
return
{
...
@@ -261,13 +269,7 @@ export class UpdateService extends ConsoleLogger {
...
@@ -261,13 +269,7 @@ export class UpdateService extends ConsoleLogger {
}
}
const
packagePlans
:
Archive
[][]
=
[];
const
packagePlans
:
Archive
[][]
=
[];
const
partArchives
=
await
this
.
db
const
partArchives
=
await
getArchives
(
ArchiveType
.
Part
);
.
getRepository
(
Archive
)
.
createQueryBuilder
(
'
archive
'
)
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
,
'
archive.files
'
])
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
.
andWhere
(
'
archive.role = :partRole
'
,
{
partRole
:
ArchiveType
.
Part
})
.
getMany
();
// Plan 1: use all part archives
// Plan 1: use all part archives
const
suitablePartArchives
=
this
.
pickArchives
(
partArchives
,
requestedFiles
);
const
suitablePartArchives
=
this
.
pickArchives
(
partArchives
,
requestedFiles
);
...
@@ -286,16 +288,15 @@ export class UpdateService extends ConsoleLogger {
...
@@ -286,16 +288,15 @@ export class UpdateService extends ConsoleLogger {
// console.log(`2 update ${useArchive}`);
// console.log(`2 update ${useArchive}`);
packagePlans
.
push
([
useArchive
]);
packagePlans
.
push
([
useArchive
]);
}
else
{
}
else
{
const
fullArchive
=
await
this
.
db
const
fullsArchives
=
await
getArchives
(
ArchiveType
.
Fulls
);
.
getRepository
(
Archive
)
if
(
fullsArchives
.
length
)
{
.
createQueryBuilder
(
'
archive
'
)
const
suitableFulls
=
this
.
pickArchives
(
fullsArchives
,
requestedFiles
);
.
select
([
'
archive.hash
'
,
'
archive.path
'
,
'
archive.size
'
])
packagePlans
.
push
(
suitableFulls
?.
length
?
suitableFulls
:
fullsArchives
);
.
where
(
'
archive.buildId = :buildId
'
,
{
buildId
:
build
.
id
})
}
else
{
.
andWhere
(
'
archive.role = :fullRole
'
,
{
fullRole
:
ArchiveType
.
Full
})
const
fullArchive
=
await
getSingleArchive
(
ArchiveType
.
Full
);
.
limit
(
1
)
// console.log(`2 full ${fullArchive}`);
.
getOneOrFail
();
packagePlans
.
push
([
fullArchive
]);
// console.log(`2 full ${fullArchive}`);
}
packagePlans
.
push
([
fullArchive
]);
}
}
if
(
bestUpdateArchive
)
{
if
(
bestUpdateArchive
)
{
...
...
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