Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Jetsam Server
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jetsam
Jetsam Server
Commits
08492502
Verified
Commit
08492502
authored
3 years ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Script for checking upload status
parent
8be06cdd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/check_img.js
+44
-0
44 additions, 0 deletions
scripts/check_img.js
with
44 additions
and
0 deletions
scripts/check_img.js
0 → 100644
+
44
−
0
View file @
08492502
async
function
main
()
{
const
{
URL
}
=
require
(
'
url
'
)
const
{
Upload
}
=
require
(
'
database/models
'
)
const
{
fs
}
=
require
(
'
services
'
)
let
uploads
=
[]
const
total
=
await
Upload
.
count
({
where
:
{
status
:
'
pending
'
}
})
let
count
=
0
uploads
=
await
Upload
.
findAll
({
limit
:
25
,
order
:
[
'
created_at
'
],
where
:
{
status
:
'
pending
'
}
})
while
(
uploads
.
length
>
0
)
{
console
.
log
(
'
Processing entries %d to %d, of total %d
'
,
count
,
count
+
uploads
.
length
,
total
)
count
+=
uploads
.
length
for
(
const
upload
of
uploads
)
{
await
new
Promise
(
r
=>
setTimeout
(
r
,
50
))
// const path = `${ upload.user_id }/${ upload.id }.jpg`
const
url
=
new
URL
(
upload
.
upload_url
)
url
.
search
=
''
const
[
_
,
bucket
,
...
pathParts
]
=
url
.
pathname
.
split
(
'
/
'
)
const
path
=
pathParts
.
join
(
'
/
'
)
try
{
await
fs
.
makePublic
(
path
)
}
catch
(
e
)
{
console
.
error
(
'
Couldnt make
'
,
path
,
'
public
'
)
upload
.
status
=
'
failed
'
upload
.
status_reason
=
'
bogus upload url
'
await
upload
.
save
()
continue
}
console
.
log
(
url
.
toString
())
upload
.
status
=
'
success
'
await
upload
.
save
()
}
await
new
Promise
(
r
=>
setTimeout
(
r
,
500
))
uploads
=
await
Upload
.
findAll
({
limit
:
25
,
order
:
[
'
created_at
'
],
where
:
{
status
:
'
pending
'
}
})
}
process
.
exit
(
0
)
}
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment