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
741d633a
Commit
741d633a
authored
Jul 14, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update console-api/src/s3/s3.service.ts
parent
ccbcaee7
Pipeline
#39020
passed with stages
in 1 minute and 34 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
console-api/src/s3/s3.service.ts
console-api/src/s3/s3.service.ts
+10
-9
No files found.
console-api/src/s3/s3.service.ts
View file @
741d633a
...
@@ -66,14 +66,14 @@ export class S3Service extends ConsoleLogger {
...
@@ -66,14 +66,14 @@ export class S3Service extends ConsoleLogger {
async
removeObjects
(
paths
:
string
[])
{
async
removeObjects
(
paths
:
string
[])
{
const
CHUNK_SIZE
=
1000
;
const
CHUNK_SIZE
=
1000
;
//
按 1000 一组分割
//
分块
const
chunks
=
[];
const
chunks
:
string
[][]
=
[];
for
(
let
i
=
0
;
i
<
paths
.
length
;
i
+=
CHUNK_SIZE
)
{
for
(
let
i
=
0
;
i
<
paths
.
length
;
i
+=
CHUNK_SIZE
)
{
chunks
.
push
(
paths
.
slice
(
i
,
i
+
CHUNK_SIZE
));
chunks
.
push
(
paths
.
slice
(
i
,
i
+
CHUNK_SIZE
));
}
}
//
顺序执行每组删除
//
构造所有 delete 命令的 promise
for
(
const
chunk
of
chunks
)
{
const
deletePromises
=
chunks
.
map
((
chunk
)
=>
{
const
command
=
new
DeleteObjectsCommand
({
const
command
=
new
DeleteObjectsCommand
({
Bucket
:
this
.
bucket
,
Bucket
:
this
.
bucket
,
Delete
:
{
Delete
:
{
...
@@ -83,12 +83,13 @@ async removeObjects(paths: string[]) {
...
@@ -83,12 +83,13 @@ async removeObjects(paths: string[]) {
},
},
});
});
try
{
return
this
.
s3
.
send
(
command
).
catch
((
e
)
=>
{
await
this
.
s3
.
send
(
command
);
}
catch
(
e
)
{
this
.
error
(
`Failed to remove
${
chunk
.
length
}
S3 objects:
${
e
}
`
);
this
.
error
(
`Failed to remove
${
chunk
.
length
}
S3 objects:
${
e
}
`
);
}
});
}
});
// 并发执行全部请求
await
Promise
.
all
(
deletePromises
);
}
}
async
fileExists
(
path
:
string
)
{
async
fileExists
(
path
:
string
)
{
...
...
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