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
cdc3e853
Commit
cdc3e853
authored
Aug 05, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one build per app
parent
3f81a889
Pipeline
#39939
passed with stages
in 7 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
40 deletions
+45
-40
console-api/src/app.service.ts
console-api/src/app.service.ts
+45
-40
No files found.
console-api/src/app.service.ts
View file @
cdc3e853
...
@@ -21,6 +21,7 @@ import { AssetsS3Service } from './assets-s3/assets-s3.service';
...
@@ -21,6 +21,7 @@ import { AssetsS3Service } from './assets-s3/assets-s3.service';
import
{
Redis
}
from
'
ioredis
'
;
import
{
Redis
}
from
'
ioredis
'
;
import
{
InjectRedis
}
from
'
@nestjs-modules/ioredis
'
;
import
{
InjectRedis
}
from
'
@nestjs-modules/ioredis
'
;
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
BetterLock
from
'
better-lock
'
;
@
Injectable
()
@
Injectable
()
export
class
AppService
extends
ConsoleLogger
{
export
class
AppService
extends
ConsoleLogger
{
...
@@ -181,6 +182,8 @@ export class AppService extends ConsoleLogger {
...
@@ -181,6 +182,8 @@ export class AppService extends ConsoleLogger {
return
this
.
db
.
getRepository
(
Build
).
findOne
({
where
:
{
depot
,
version
},
select
:
[
'
id
'
]
});
return
this
.
db
.
getRepository
(
Build
).
findOne
({
where
:
{
depot
,
version
},
select
:
[
'
id
'
]
});
}
}
private
buildLock
=
new
BetterLock
();
async
makeBuild
(
user
:
MyCardUser
,
stream
:
NodeJS
.
ReadableStream
,
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
)
{
async
makeBuild
(
user
:
MyCardUser
,
stream
:
NodeJS
.
ReadableStream
,
id
:
string
,
depotDto
:
DepotDto
,
version
:
string
)
{
if
(
!
user
)
{
if
(
!
user
)
{
throw
new
BlankReturnMessageDto
(
401
,
'
Needs login
'
).
toException
();
throw
new
BlankReturnMessageDto
(
401
,
'
Needs login
'
).
toException
();
...
@@ -203,49 +206,51 @@ export class AppService extends ConsoleLogger {
...
@@ -203,49 +206,51 @@ export class AppService extends ConsoleLogger {
let
build
=
new
Build
();
let
build
=
new
Build
();
build
.
depot
=
depot
;
build
.
depot
=
depot
;
build
.
version
=
version
;
build
.
version
=
version
;
this
.
log
(
`Start packaging
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
.`
);
return
this
.
buildLock
.
acquire
(
id
,
async
()
=>
{
try
{
this
.
log
(
`Start packaging
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
.`
);
const
previousTracingBuildChecksums
=
(
try
{
await
this
.
db
const
previousTracingBuildChecksums
=
(
.
getRepository
(
Build
)
await
this
.
db
.
find
({
where
:
{
depot
},
order
:
{
id
:
'
DESC
'
},
select
:
[
'
id
'
,
'
checksum
'
],
take
:
this
.
packageVersionTraceCount
})
.
getRepository
(
Build
)
).
map
((
b
)
=>
b
.
checksum
);
.
find
({
where
:
{
depot
},
order
:
{
id
:
'
DESC
'
},
select
:
[
'
id
'
,
'
checksum
'
],
take
:
this
.
packageVersionTraceCount
})
const
result
=
await
this
.
packager
.
build
(
stream
,
app
.
packagePrefix
,
previousTracingBuildChecksums
);
).
map
((
b
)
=>
b
.
checksum
);
this
.
log
(
`Saving package info of
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
const
result
=
await
this
.
packager
.
build
(
stream
,
app
.
packagePrefix
,
previousTracingBuildChecksums
);
build
.
checksum
=
result
.
checksum
;
this
.
log
(
`Saving package info of
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
//build.archives = result.archives;
build
.
checksum
=
result
.
checksum
;
//build = await this.db.getRepository(Build).save(build);
//build.archives = result.archives;
//build = await this.db.getRepository(Build).save(build);
await
this
.
db
.
transaction
(
async
(
edb
)
=>
{
this
.
log
(
`Saving build info.`
);
await
this
.
db
.
transaction
(
async
(
edb
)
=>
{
build
=
await
edb
.
getRepository
(
Build
).
save
(
build
);
this
.
log
(
`Saving build info.`
);
let
archivePot
:
Archive
[]
=
[];
build
=
await
edb
.
getRepository
(
Build
).
save
(
build
);
let
currentSize
=
0
;
let
archivePot
:
Archive
[]
=
[];
for
(
const
archive
of
result
.
archives
)
{
let
currentSize
=
0
;
archive
.
build
=
build
;
for
(
const
archive
of
result
.
archives
)
{
const
size
=
archive
.
getParamSize
();
archive
.
build
=
build
;
if
(
currentSize
>
0
&&
currentSize
+
size
>
60000
)
{
const
size
=
archive
.
getParamSize
();
if
(
currentSize
>
0
&&
currentSize
+
size
>
60000
)
{
this
.
log
(
`Saving
${
archivePot
.
length
}
archive infos.`
);
await
edb
.
getRepository
(
Archive
).
save
(
archivePot
);
archivePot
=
[];
currentSize
=
0
;
}
archivePot
.
push
(
archive
);
currentSize
+=
size
;
}
if
(
archivePot
.
length
)
{
this
.
log
(
`Saving
${
archivePot
.
length
}
archive infos.`
);
this
.
log
(
`Saving
${
archivePot
.
length
}
archive infos.`
);
await
edb
.
getRepository
(
Archive
).
save
(
archivePot
);
await
edb
.
getRepository
(
Archive
).
save
(
archivePot
);
archivePot
=
[];
currentSize
=
0
;
}
}
archivePot
.
push
(
archive
);
});
currentSize
+=
size
;
}
this
.
mirror
.
triggerMirror
();
if
(
archivePot
.
length
)
{
this
.
log
(
`Finished packaging
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
this
.
log
(
`Saving
${
archivePot
.
length
}
archive infos.`
);
return
new
BlankReturnMessageDto
(
201
,
'
success
'
);
await
edb
.
getRepository
(
Archive
).
save
(
archivePot
);
}
catch
(
e
)
{
}
this
.
error
(
`Build
${
app
.
id
}
${
JSON
.
stringify
(
depotDto
.
toActual
)}
${
build
.
version
}
failed:
${
e
.
toString
()}
`
);
});
throw
new
BlankReturnMessageDto
(
500
,
'
Build failed
'
).
toException
();
}
this
.
mirror
.
triggerMirror
();
})
this
.
log
(
`Finished packaging
${
app
.
id
}
${
version
}
for
${
JSON
.
stringify
(
depot
)}
`
);
return
new
BlankReturnMessageDto
(
201
,
'
success
'
);
}
catch
(
e
)
{
this
.
error
(
`Build
${
app
.
id
}
${
JSON
.
stringify
(
depotDto
.
toActual
)}
${
build
.
version
}
failed:
${
e
.
toString
()}
`
);
throw
new
BlankReturnMessageDto
(
500
,
'
Build failed
'
).
toException
();
}
}
}
private
packageReferenceSubQuery
(
query
:
SelectQueryBuilder
<
any
>
)
{
private
packageReferenceSubQuery
(
query
:
SelectQueryBuilder
<
any
>
)
{
...
...
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