Improve drive management
This commit is contained in:
parent
9403ee6495
commit
72fb23f4d5
14 changed files with 152 additions and 54 deletions
|
@ -1,26 +0,0 @@
|
|||
import * as promiseLimit from 'promise-limit';
|
||||
import del from '../services/drive/delete-file';
|
||||
import { DriveFiles } from '../models';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { DriveFile } from '../models/entities/drive-file';
|
||||
import { ensure } from '../prelude/ensure';
|
||||
|
||||
const limit = promiseLimit(16);
|
||||
|
||||
DriveFiles.find({
|
||||
userHost: Not(IsNull())
|
||||
}).then(async files => {
|
||||
console.log(`there is ${files.length} files`);
|
||||
|
||||
await Promise.all(files.map(file => limit(() => job(file))));
|
||||
|
||||
console.log('ALL DONE');
|
||||
});
|
||||
|
||||
async function job(file: DriveFile): Promise<any> {
|
||||
file = await DriveFiles.findOne(file.id).then(ensure);
|
||||
|
||||
await del(file, true);
|
||||
|
||||
console.log('done', file.id);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue