Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
338
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
28
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
bcf28282
Commit
bcf28282
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
✌️
parent
abfbb068
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cli/clean-drive.js
+19
-15
19 additions, 15 deletions
cli/clean-drive.js
with
19 additions
and
15 deletions
cli/clean-drive.js
+
19
−
15
View file @
bcf28282
...
...
@@ -16,19 +16,23 @@ async function main() {
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
promiseGens
.
push
(()
=>
{
const
promise
=
new
Promise
(
async
(
res
,
rej
)
=>
{
function
skip
()
{
res
([
i
,
file
,
false
]);
}
const
file
=
await
DriveFile
.
findOne
(
prev
?
{
_id
:
{
$
g
t
:
prev
.
_id
}
_id
:
{
$
l
t
:
prev
.
_id
}
}
:
{},
{
sort
:
{
_id
:
1
_id
:
-
1
}
});
prev
=
file
;
if
(
file
==
null
)
return
res
();
if
(
file
==
null
)
return
skip
();
log
(
chalk
`scanning: {bold
${
file
.
_id
}
} ...`
);
log
(
chalk
`
{gray
${
i
}
}
scanning: {bold
${
file
.
_id
}
} ...`
);
const
attachingUsersCount
=
await
User
.
count
({
$or
:
[{
...
...
@@ -37,28 +41,28 @@ async function main() {
bannerId
:
file
.
_id
}]
},
{
limit
:
1
});
if
(
attachingUsersCount
!==
0
)
return
res
();
if
(
attachingUsersCount
!==
0
)
return
skip
();
const
attachingNotesCount
=
await
Note
.
count
({
mediaIds
:
file
.
_id
},
{
limit
:
1
});
if
(
attachingNotesCount
!==
0
)
return
res
();
if
(
attachingNotesCount
!==
0
)
return
skip
();
const
attachingMessagesCount
=
await
MessagingMessage
.
count
({
fileId
:
file
.
_id
},
{
limit
:
1
});
if
(
attachingMessagesCount
!==
0
)
return
res
();
if
(
attachingMessagesCount
!==
0
)
return
skip
();
deleteDriveFile
(
file
).
then
(
res
).
catch
(
rej
);
deleteDriveFile
(
file
).
then
(()
=>
{
res
([
i
,
file
,
true
]);
}).
catch
(
rej
);
});
promise
.
then
(
x
=>
{
if
(
prev
)
{
if
(
x
==
null
)
{
log
(
chalk
`{green skipped: {bold
${
prev
.
_id
}
}}`
);
}
else
{
log
(
chalk
`{red deleted: {bold
${
prev
.
_id
}
}}`
);
}
promise
.
then
(([
i
,
file
,
deleted
])
=>
{
if
(
deleted
)
{
log
(
chalk
`{gray
${
i
}
} {red deleted: {bold
${
file
.
_id
}
}}`
);
}
else
{
log
(
chalk
`{gray
${
i
}
} {green skipped: {bold
${
file
.
_id
}
}}`
);
}
log
.
clear
();
console
.
log
();
...
...
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