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
876dd458
Commit
876dd458
authored
Sep 07, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check hash from remote
parent
9291d82e
Pipeline
#5391
passed with stages
in 2 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
console-api/src/app.service.ts
console-api/src/app.service.ts
+10
-6
console-api/src/packager/packager.service.ts
console-api/src/packager/packager.service.ts
+8
-12
No files found.
console-api/src/app.service.ts
View file @
876dd458
...
...
@@ -340,20 +340,24 @@ export class AppService extends ConsoleLogger {
if
(
archive
)
{
return
archive
.
hash
;
}
return
null
;
return
this
.
checkHashFromUrl
(
`
${
this
.
packageS3
.
cdnUrl
}
/
${
path
}
.tar.zst`
)
;
}
async
getHashForMigrate
(
fullPath
:
string
):
Promise
<
string
>
{
const
url
=
`
${
this
.
packageS3
.
cdnUrl
}
/
${
fullPath
}
`
;
this
.
log
(
`Migrating hash:
${
url
}
`
);
async
checkHashFromUrl
(
url
:
string
)
{
const
{
data
}
=
await
axios
.
get
<
internal
.
Readable
>
(
url
,
{
responseType
:
'
stream
'
});
//data.pipe(hashObject);
const
hash
=
await
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
const
hashObject
=
createHash
(
'
sha256
'
);
data
.
on
(
'
data
'
,
(
data
)
=>
hashObject
.
update
(
data
));
data
.
on
(
'
error
'
,
reject
);
data
.
on
(
'
end
'
,
()
=>
resolve
(
hashObject
.
digest
(
'
hex
'
)));
});
}
async
getHashForMigrate
(
fullPath
:
string
):
Promise
<
string
>
{
const
url
=
`
${
this
.
packageS3
.
cdnUrl
}
/
${
fullPath
}
`
;
this
.
log
(
`Migrating hash:
${
url
}
`
);
const
hash
=
await
this
.
checkHashFromUrl
(
url
);
this
.
log
(
`Migrated hash:
${
url
}
=>
${
hash
}
`
);
return
hash
;
}
...
...
console-api/src/packager/packager.service.ts
View file @
876dd458
...
...
@@ -16,6 +16,8 @@ import { AppService } from '../app.service';
import
{
createHash
}
from
'
crypto
'
;
import
delay
from
'
delay
'
;
import
{
Cache
}
from
'
@cityssm/map-expire
'
;
import
axios
from
'
axios
'
;
import
internal
from
'
stream
'
;
export
interface
FileWithHash
{
file
:
readdirp
.
EntryInfo
;
...
...
@@ -207,11 +209,8 @@ export class PackagerService extends ConsoleLogger {
return
hash
;
}
hash
=
await
this
.
appService
.
lookForExistingArchiveHash
(
path
);
if
(
hash
)
{
this
.
hashCache
.
set
(
path
,
hash
,
24
*
60
*
60
*
1000
);
return
hash
;
}
return
null
;
this
.
hashCache
.
set
(
path
,
hash
,
24
*
60
*
60
*
1000
);
return
hash
;
}
async
archive
(
root
:
string
,
archiveTask
:
ArchiveTask
):
Promise
<
Archive
>
{
...
...
@@ -220,13 +219,10 @@ export class PackagerService extends ConsoleLogger {
await
this
.
waitForLock
(
archiveTask
.
path
);
const
existing
=
await
this
.
s3
.
fileExists
(
archiveName
);
if
(
existing
)
{
const
hash
=
await
this
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
if
(
hash
)
{
this
.
log
(
`Archive
${
archiveName
}
exists, skipping.`
);
archive
.
size
=
existing
.
Size
;
archive
.
hash
=
hash
;
return
archive
;
}
archive
.
hash
=
await
this
.
lookForExistingArchiveHash
(
archiveTask
.
path
);
archive
.
size
=
existing
.
Size
;
this
.
log
(
`Archive
${
archiveName
}
exists, skipping.`
);
return
archive
;
}
const
files
=
archiveTask
.
filePaths
;
this
.
log
(
`Packaging archive
${
archiveName
}
with
${
archiveTask
.
exactFilePaths
.
length
}
files.`
);
...
...
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