✌️
This commit is contained in:
parent
abfbb068d7
commit
bcf28282f6
@ -16,19 +16,23 @@ async function main() {
|
|||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
promiseGens.push(() => {
|
promiseGens.push(() => {
|
||||||
const promise = new Promise(async (res, rej) => {
|
const promise = new Promise(async (res, rej) => {
|
||||||
|
function skip() {
|
||||||
|
res([i, file, false]);
|
||||||
|
}
|
||||||
|
|
||||||
const file = await DriveFile.findOne(prev ? {
|
const file = await DriveFile.findOne(prev ? {
|
||||||
_id: { $gt: prev._id }
|
_id: { $lt: prev._id }
|
||||||
} : {}, {
|
} : {}, {
|
||||||
sort: {
|
sort: {
|
||||||
_id: 1
|
_id: -1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
prev = file;
|
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({
|
const attachingUsersCount = await User.count({
|
||||||
$or: [{
|
$or: [{
|
||||||
@ -37,28 +41,28 @@ async function main() {
|
|||||||
bannerId: file._id
|
bannerId: file._id
|
||||||
}]
|
}]
|
||||||
}, { limit: 1 });
|
}, { limit: 1 });
|
||||||
if (attachingUsersCount !== 0) return res();
|
if (attachingUsersCount !== 0) return skip();
|
||||||
|
|
||||||
const attachingNotesCount = await Note.count({
|
const attachingNotesCount = await Note.count({
|
||||||
mediaIds: file._id
|
mediaIds: file._id
|
||||||
}, { limit: 1 });
|
}, { limit: 1 });
|
||||||
if (attachingNotesCount !== 0) return res();
|
if (attachingNotesCount !== 0) return skip();
|
||||||
|
|
||||||
const attachingMessagesCount = await MessagingMessage.count({
|
const attachingMessagesCount = await MessagingMessage.count({
|
||||||
fileId: file._id
|
fileId: file._id
|
||||||
}, { limit: 1 });
|
}, { 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 => {
|
promise.then(([i, file, deleted]) => {
|
||||||
if (prev) {
|
if (deleted) {
|
||||||
if (x == null) {
|
log(chalk`{gray ${i}} {red deleted: {bold ${file._id}}}`);
|
||||||
log(chalk`{green skipped: {bold ${prev._id}}}`);
|
} else {
|
||||||
} else {
|
log(chalk`{gray ${i}} {green skipped: {bold ${file._id}}}`);
|
||||||
log(chalk`{red deleted: {bold ${prev._id}}}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
log.clear();
|
log.clear();
|
||||||
console.log();
|
console.log();
|
||||||
|
Loading…
Reference in New Issue
Block a user