Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
27f90b61e6 | |||
c9a57fe8fe | |||
9516f2fa63 |
56
cli/clean-drive.js
Normal file
56
cli/clean-drive.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
const sequential = require('promise-sequential');
|
||||||
|
const { default: DriveFile, deleteDriveFile } = require('../built/models/drive-file');
|
||||||
|
const { default: Note } = require('../built/models/note');
|
||||||
|
const { default: MessagingMessage } = require('../built/models/messaging-message');
|
||||||
|
const { default: User } = require('../built/models/user');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const promiseGens = [];
|
||||||
|
|
||||||
|
const count = await DriveFile.count({});
|
||||||
|
|
||||||
|
let prev;
|
||||||
|
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
promiseGens.push(() => new Promise(async (res, rej) => {
|
||||||
|
const file = await DriveFile.findOne(prev ? {
|
||||||
|
_id: { $gt: prev._id }
|
||||||
|
} : {}, {
|
||||||
|
sort: {
|
||||||
|
_id: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prev = file;
|
||||||
|
|
||||||
|
console.log(`scanning ${file._id}`);
|
||||||
|
|
||||||
|
const attachingUsersCount = await User.count({
|
||||||
|
$or: [{
|
||||||
|
avatarId: file._id
|
||||||
|
}, {
|
||||||
|
bannerId: file._id
|
||||||
|
}]
|
||||||
|
}, { limit: 1 });
|
||||||
|
if (attachingUsersCount !== 0) return res();
|
||||||
|
|
||||||
|
const attachingNotesCount = await Note.count({
|
||||||
|
mediaIds: file._id
|
||||||
|
}, { limit: 1 });
|
||||||
|
if (attachingNotesCount !== 0) return res();
|
||||||
|
|
||||||
|
const attachingMessagesCount = await MessagingMessage.count({
|
||||||
|
fileId: file._id
|
||||||
|
}, { limit: 1 });
|
||||||
|
if (attachingMessagesCount !== 0) return res();
|
||||||
|
|
||||||
|
console.log(`deleting ${file._id}`);
|
||||||
|
|
||||||
|
deleteDriveFile(file).then(res).catch(rej);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return await sequential(promiseGens);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().then(console.dir).catch(console.error);
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"author": "syuilo <i@syuilo.com>",
|
"author": "syuilo <i@syuilo.com>",
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"clientVersion": "1.0.5172",
|
"clientVersion": "1.0.5175",
|
||||||
"codename": "nighthike",
|
"codename": "nighthike",
|
||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
@ -165,6 +165,7 @@
|
|||||||
"os-utils": "0.0.14",
|
"os-utils": "0.0.14",
|
||||||
"progress-bar-webpack-plugin": "1.11.0",
|
"progress-bar-webpack-plugin": "1.11.0",
|
||||||
"prominence": "0.2.0",
|
"prominence": "0.2.0",
|
||||||
|
"promise-sequential": "^1.1.1",
|
||||||
"pug": "2.0.3",
|
"pug": "2.0.3",
|
||||||
"punycode": "2.1.0",
|
"punycode": "2.1.0",
|
||||||
"qrcode": "1.2.0",
|
"qrcode": "1.2.0",
|
||||||
|
@ -16,6 +16,7 @@ const fetchLimit = 10;
|
|||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: ['user', 'withMedia'],
|
props: ['user', 'withMedia'],
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
fetching: true,
|
fetching: true,
|
||||||
@ -23,9 +24,17 @@ export default Vue.extend({
|
|||||||
moreFetching: false
|
moreFetching: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
canFetchMore(): boolean {
|
||||||
|
return !this.moreFetching && !this.fetching && this.existMore;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetch() {
|
fetch() {
|
||||||
this.fetching = true;
|
this.fetching = true;
|
||||||
@ -45,7 +54,10 @@ export default Vue.extend({
|
|||||||
}, rej);
|
}, rej);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
more() {
|
more() {
|
||||||
|
if (!this.canFetchMore) return;
|
||||||
|
|
||||||
this.moreFetching = true;
|
this.moreFetching = true;
|
||||||
(this as any).api('users/notes', {
|
(this as any).api('users/notes', {
|
||||||
userId: this.user.id,
|
userId: this.user.id,
|
||||||
|
Reference in New Issue
Block a user