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
9984d2f3
Commit
9984d2f3
authored
Feb 09, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use HeadObjectCommand for existing check
parent
3f76fec1
Pipeline
#25386
passed with stages
in 2 minutes and 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+4
-4
console-api/src/s3/s3.service.ts
console-api/src/s3/s3.service.ts
+14
-2
No files found.
console-api/src/packager/packager.service.ts
View file @
9984d2f3
...
...
@@ -217,7 +217,7 @@ export class PackagerService extends ConsoleLogger {
const
hash
=
await
this
.
appService
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
if
(
hash
)
{
archive
.
hash
=
hash
;
archive
.
size
=
existing
.
Size
;
archive
.
size
=
existing
.
ContentLength
;
this
.
log
(
`Archive
${
archiveName
}
exists, skipping.`
);
return
archive
;
}
...
...
@@ -235,7 +235,7 @@ export class PackagerService extends ConsoleLogger {
const
hash
=
await
this
.
appService
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
if
(
hash
)
{
archive
.
hash
=
hash
;
archive
.
size
=
existing
.
Size
;
archive
.
size
=
existing
.
ContentLength
;
this
.
log
(
`Archive
${
archiveName
}
exists, skipping.`
);
return
archive
;
}
...
...
@@ -274,7 +274,7 @@ export class PackagerService extends ConsoleLogger {
let
tmpFilename
:
string
;
try
{
if
(
files
.
length
>
1000
)
{
/*
if (files.length > 1000) {
this.warn(`Too many files in archive ${archiveName}, using tmp file.`);
// minio would skew the stream if it's too slow
...
...
@@ -290,7 +290,7 @@ export class PackagerService extends ConsoleLogger {
});
// open the tmp file as a new stream
uploadStream = fs.createReadStream(tmpFilename);
}
}
*/
const
uploadPromise
=
this
.
s3
.
uploadStream
(
archiveName
,
uploadStream
,
{
ContentType
:
'
application/tar+zstd
'
,
...
...
console-api/src/s3/s3.service.ts
View file @
9984d2f3
...
...
@@ -3,6 +3,7 @@ import { ConfigService } from '@nestjs/config';
import
{
_Object
,
DeleteObjectsCommand
,
HeadObjectCommand
,
ListObjectsCommand
,
PutObjectCommand
,
PutObjectCommandInput
,
...
...
@@ -75,9 +76,20 @@ export class S3Service extends ConsoleLogger {
}
async
fileExists
(
path
:
string
)
{
const
objects
=
await
this
.
listObjects
(
path
);
//
const objects = await this.listObjects(path);
// this.log(objects);
return
objects
.
Contents
?
objects
.
Contents
.
find
((
obj
)
=>
obj
.
Key
===
this
.
getPathWithPrefix
(
path
))
:
null
;
// return objects.Contents ? objects.Contents.find((obj) => obj.Key === this.getPathWithPrefix(path)) : null;
try
{
const
res
=
await
this
.
s3
.
send
(
new
HeadObjectCommand
({
Bucket
:
this
.
bucket
,
Key
:
this
.
getPathWithPrefix
(
path
),
})
);
return
res
;
}
catch
(
e
)
{
return
;
}
}
private
getPathWithPrefix
(
filename
:
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