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
13962ae6
Commit
13962ae6
authored
Oct 09, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add force pack
parent
aa40d41a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
21 deletions
+34
-21
console-api/src/app.controller.ts
console-api/src/app.controller.ts
+2
-2
console-api/src/app.service.ts
console-api/src/app.service.ts
+3
-3
console-api/src/dto/Depot.dto.ts
console-api/src/dto/Depot.dto.ts
+5
-0
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+24
-16
No files found.
console-api/src/app.controller.ts
View file @
13962ae6
...
@@ -23,7 +23,7 @@ import { FileUploadDto } from './dto/FileUpload.dto';
...
@@ -23,7 +23,7 @@ import { FileUploadDto } from './dto/FileUpload.dto';
import
Busboy
from
'
busboy
'
;
import
Busboy
from
'
busboy
'
;
import
{
Request
}
from
'
express
'
;
import
{
Request
}
from
'
express
'
;
import
{
PackageResult
}
from
'
./dto/PackageResult.dto
'
;
import
{
PackageResult
}
from
'
./dto/PackageResult.dto
'
;
import
{
DepotDto
}
from
'
./dto/Depot.dto
'
;
import
{
DepotDto
,
MakeBuildDto
}
from
'
./dto/Depot.dto
'
;
import
AppClass
=
AppsJson
.
AppClass
;
import
AppClass
=
AppsJson
.
AppClass
;
@
Controller
(
'
api
'
)
@
Controller
(
'
api
'
)
...
@@ -109,7 +109,7 @@ export class AppController {
...
@@ -109,7 +109,7 @@ export class AppController {
async
makeBuild
(
async
makeBuild
(
@
FetchMyCardUser
()
user
:
MyCardUser
,
@
FetchMyCardUser
()
user
:
MyCardUser
,
@
Param
(
'
id
'
)
id
:
string
,
@
Param
(
'
id
'
)
id
:
string
,
@
Query
(
new
ValidationPipe
({
transform
:
true
}))
depot
:
Depot
Dto
,
@
Query
(
new
ValidationPipe
({
transform
:
true
}))
depot
:
MakeBuild
Dto
,
@
Param
(
'
version
'
)
version
:
string
,
@
Param
(
'
version
'
)
version
:
string
,
@
Req
()
req
:
Request
@
Req
()
req
:
Request
)
{
)
{
...
...
console-api/src/app.service.ts
View file @
13962ae6
...
@@ -8,7 +8,7 @@ import { MyCardUser } from './utility/mycard-auth';
...
@@ -8,7 +8,7 @@ import { MyCardUser } from './utility/mycard-auth';
import
{
PackagerService
}
from
'
./packager/packager.service
'
;
import
{
PackagerService
}
from
'
./packager/packager.service
'
;
import
internal
from
'
stream
'
;
import
internal
from
'
stream
'
;
import
{
Depot
}
from
'
./entities/Depot.entity
'
;
import
{
Depot
}
from
'
./entities/Depot.entity
'
;
import
{
DepotDto
}
from
'
./dto/Depot.dto
'
;
import
{
DepotDto
,
MakeBuildDto
}
from
'
./dto/Depot.dto
'
;
import
{
Build
}
from
'
./entities/Build.entity
'
;
import
{
Build
}
from
'
./entities/Build.entity
'
;
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
{
Archive
,
ArchiveType
}
from
'
./entities/Archive.entity
'
;
import
{
Archive
,
ArchiveType
}
from
'
./entities/Archive.entity
'
;
...
@@ -184,7 +184,7 @@ export class AppService extends ConsoleLogger {
...
@@ -184,7 +184,7 @@ export class AppService extends ConsoleLogger {
private
buildLock
=
new
BetterLock
();
private
buildLock
=
new
BetterLock
();
async
makeBuild
(
user
:
MyCardUser
,
stream
:
NodeJS
.
ReadableStream
,
id
:
string
,
depotDto
:
Depot
Dto
,
version
:
string
)
{
async
makeBuild
(
user
:
MyCardUser
,
stream
:
NodeJS
.
ReadableStream
,
id
:
string
,
depotDto
:
MakeBuild
Dto
,
version
:
string
)
{
if
(
!
user
)
{
if
(
!
user
)
{
throw
new
BlankReturnMessageDto
(
401
,
'
Needs login
'
).
toException
();
throw
new
BlankReturnMessageDto
(
401
,
'
Needs login
'
).
toException
();
}
}
...
@@ -214,7 +214,7 @@ export class AppService extends ConsoleLogger {
...
@@ -214,7 +214,7 @@ export class AppService extends ConsoleLogger {
.
getRepository
(
Build
)
.
getRepository
(
Build
)
.
find
({
where
:
{
depot
},
order
:
{
id
:
'
DESC
'
},
select
:
[
'
id
'
,
'
checksum
'
],
take
:
this
.
packageVersionTraceCount
})
.
find
({
where
:
{
depot
},
order
:
{
id
:
'
DESC
'
},
select
:
[
'
id
'
,
'
checksum
'
],
take
:
this
.
packageVersionTraceCount
})
).
map
((
b
)
=>
b
.
checksum
);
).
map
((
b
)
=>
b
.
checksum
);
const
result
=
await
this
.
packager
.
build
(
stream
,
app
.
packagePrefix
,
previousTracingBuildChecksums
);
const
result
=
await
this
.
packager
.
build
(
stream
,
app
.
packagePrefix
,
previousTracingBuildChecksums
,
!!
depotDto
.
force
);
this
.
log
(
`Saving package info of
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
this
.
log
(
`Saving package info of
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
build
.
checksum
=
result
.
checksum
;
build
.
checksum
=
result
.
checksum
;
//build.archives = result.archives;
//build.archives = result.archives;
...
...
console-api/src/dto/Depot.dto.ts
View file @
13962ae6
...
@@ -44,3 +44,8 @@ export class DepotDto implements DepotLike {
...
@@ -44,3 +44,8 @@ export class DepotDto implements DepotLike {
});
});
}
}
}
}
export
class
MakeBuildDto
extends
DepotDto
{
@
ApiProperty
({
description
:
'
是否强制重新打包
'
,
required
:
false
})
force
?:
boolean
;
}
console-api/src/packager/packager.service.ts
View file @
13962ae6
...
@@ -28,7 +28,12 @@ const ARG_SIZE_LIMIT = 30000;
...
@@ -28,7 +28,12 @@ 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
[],
public
readonly
force
?:
boolean
)
{
this
.
path
=
createHash
(
'
sha512
'
)
this
.
path
=
createHash
(
'
sha512
'
)
.
update
(
files
.
map
((
f
)
=>
`
${
f
.
file
.
path
}${
f
.
hash
}
`
).
join
(
''
))
.
update
(
files
.
map
((
f
)
=>
`
${
f
.
file
.
path
}${
f
.
hash
}
`
).
join
(
''
))
.
digest
(
'
hex
'
);
.
digest
(
'
hex
'
);
...
@@ -112,7 +117,8 @@ export class PackagerService extends ConsoleLogger {
...
@@ -112,7 +117,8 @@ export class PackagerService extends ConsoleLogger {
async
build
(
async
build
(
stream
:
NodeJS
.
ReadableStream
,
stream
:
NodeJS
.
ReadableStream
,
pathPrefix
?:
string
,
pathPrefix
?:
string
,
lastBuildChecksums
:
Record
<
string
,
string
>
[]
=
[]
lastBuildChecksums
:
Record
<
string
,
string
>
[]
=
[],
force
?:
boolean
):
Promise
<
PackageResult
>
{
):
Promise
<
PackageResult
>
{
this
.
log
(
`Start packaging.`
);
this
.
log
(
`Start packaging.`
);
const
root
=
await
fs
.
promises
.
mkdtemp
(
path
.
join
(
this
.
packagerWorkingDirectory
,
'
mycard-console-
'
));
const
root
=
await
fs
.
promises
.
mkdtemp
(
path
.
join
(
this
.
packagerWorkingDirectory
,
'
mycard-console-
'
));
...
@@ -147,7 +153,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -147,7 +153,7 @@ export class PackagerService extends ConsoleLogger {
const
filesWithHash
:
FileWithHash
[]
=
files
.
map
((
file
)
=>
({
file
,
hash
:
checksum
[
file
.
path
]
}));
const
filesWithHash
:
FileWithHash
[]
=
files
.
map
((
file
)
=>
({
file
,
hash
:
checksum
[
file
.
path
]
}));
// 整包
// 整包
new
ArchiveTask
(
ArchiveType
.
Full
,
filesWithHash
,
await
fs
.
promises
.
readdir
(
root
)).
addToTask
(
archiveTasks
);
new
ArchiveTask
(
ArchiveType
.
Full
,
filesWithHash
,
await
fs
.
promises
.
readdir
(
root
)
,
force
).
addToTask
(
archiveTasks
);
if
(
files
.
length
>
1
)
{
if
(
files
.
length
>
1
)
{
// 整包(512M 一包)
// 整包(512M 一包)
...
@@ -170,7 +176,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -170,7 +176,7 @@ export class PackagerService extends ConsoleLogger {
}
}
if
(
buckets
.
length
>
1
)
{
if
(
buckets
.
length
>
1
)
{
for
(
const
bucket
of
buckets
)
{
for
(
const
bucket
of
buckets
)
{
new
ArchiveTask
(
ArchiveType
.
Fulls
,
bucket
.
files
).
addToTask
(
archiveTasks
);
new
ArchiveTask
(
ArchiveType
.
Fulls
,
bucket
.
files
,
undefined
,
force
).
addToTask
(
archiveTasks
);
}
}
this
.
log
(
`Created
${
buckets
.
length
}
fulls archives.`
);
this
.
log
(
`Created
${
buckets
.
length
}
fulls archives.`
);
}
else
{
}
else
{
...
@@ -182,7 +188,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -182,7 +188,7 @@ export class PackagerService extends ConsoleLogger {
for
(
const
lastChecksum
of
lastBuildChecksums
)
{
for
(
const
lastChecksum
of
lastBuildChecksums
)
{
const
changedFiles
=
filesWithHash
.
filter
((
f
)
=>
!
lastChecksum
[
f
.
file
.
path
]
||
lastChecksum
[
f
.
file
.
path
]
!==
f
.
hash
);
const
changedFiles
=
filesWithHash
.
filter
((
f
)
=>
!
lastChecksum
[
f
.
file
.
path
]
||
lastChecksum
[
f
.
file
.
path
]
!==
f
.
hash
);
if
(
changedFiles
.
length
)
{
if
(
changedFiles
.
length
)
{
new
ArchiveTask
(
ArchiveType
.
Update
,
changedFiles
).
addToTask
(
archiveTasks
);
new
ArchiveTask
(
ArchiveType
.
Update
,
changedFiles
,
undefined
,
force
).
addToTask
(
archiveTasks
);
}
}
}
}
}
}
...
@@ -197,17 +203,17 @@ export class PackagerService extends ConsoleLogger {
...
@@ -197,17 +203,17 @@ export class PackagerService extends ConsoleLogger {
buckets
[
extname
]
??
=
new
Bucket
();
buckets
[
extname
]
??
=
new
Bucket
();
const
bucket
=
buckets
[
extname
];
const
bucket
=
buckets
[
extname
];
if
(
!
bucket
.
canFit
(
file
,
this
.
bucket_max
))
{
if
(
!
bucket
.
canFit
(
file
,
this
.
bucket_max
))
{
new
ArchiveTask
(
ArchiveType
.
Part
,
bucket
.
files
).
addToTask
(
pendingPartTasks
,
true
);
new
ArchiveTask
(
ArchiveType
.
Part
,
bucket
.
files
,
undefined
,
force
).
addToTask
(
pendingPartTasks
,
true
);
bucket
.
empty
();
bucket
.
empty
();
}
}
bucket
.
addFile
(
file
);
bucket
.
addFile
(
file
);
}
else
{
}
else
{
new
ArchiveTask
(
ArchiveType
.
Part
,
[
file
]).
addToTask
(
pendingPartTasks
,
true
);
new
ArchiveTask
(
ArchiveType
.
Part
,
[
file
]
,
undefined
,
force
).
addToTask
(
pendingPartTasks
,
true
);
}
}
}
}
for
(
const
bucket
of
Object
.
values
(
buckets
))
{
for
(
const
bucket
of
Object
.
values
(
buckets
))
{
if
(
bucket
.
files
.
length
)
{
if
(
bucket
.
files
.
length
)
{
new
ArchiveTask
(
ArchiveType
.
Part
,
bucket
.
files
).
addToTask
(
pendingPartTasks
,
true
);
new
ArchiveTask
(
ArchiveType
.
Part
,
bucket
.
files
,
undefined
,
force
).
addToTask
(
pendingPartTasks
,
true
);
}
}
}
}
...
@@ -288,6 +294,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -288,6 +294,7 @@ export class PackagerService extends ConsoleLogger {
async
archive
(
root
:
string
,
archiveTask
:
ArchiveTask
):
Promise
<
Archive
>
{
async
archive
(
root
:
string
,
archiveTask
:
ArchiveTask
):
Promise
<
Archive
>
{
const
archive
=
archiveTask
.
archive
;
const
archive
=
archiveTask
.
archive
;
const
archiveName
=
archiveTask
.
archiveFullPath
;
const
archiveName
=
archiveTask
.
archiveFullPath
;
if
(
!
archiveTask
.
force
)
{
const
existing
=
await
this
.
s3
.
fileExists
(
archiveName
);
const
existing
=
await
this
.
s3
.
fileExists
(
archiveName
);
if
(
existing
)
{
if
(
existing
)
{
const
hash
=
await
this
.
appService
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
const
hash
=
await
this
.
appService
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
...
@@ -298,6 +305,7 @@ export class PackagerService extends ConsoleLogger {
...
@@ -298,6 +305,7 @@ export class PackagerService extends ConsoleLogger {
return
archive
;
return
archive
;
}
}
}
}
}
return
this
.
lock
.
acquire
([
`archive:
${
archiveTask
.
path
}
`
],
async
()
=>
this
.
archiveProcess
(
root
,
archiveTask
));
return
this
.
lock
.
acquire
([
`archive:
${
archiveTask
.
path
}
`
],
async
()
=>
this
.
archiveProcess
(
root
,
archiveTask
));
}
}
...
...
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