mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-25 17:33:09 +02:00
DB上で壊れたドライブファイルを無視するように (#7345)
This commit is contained in:
parent
7d02b36092
commit
ca4f026533
1 changed files with 16 additions and 14 deletions
|
@ -12,6 +12,12 @@ import { fetchMeta } from '../../misc/fetch-meta';
|
||||||
|
|
||||||
export type PackedDriveFile = SchemaType<typeof packedDriveFileSchema>;
|
export type PackedDriveFile = SchemaType<typeof packedDriveFileSchema>;
|
||||||
|
|
||||||
|
type PackOptions = {
|
||||||
|
detail?: boolean,
|
||||||
|
self?: boolean,
|
||||||
|
withUser?: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
@EntityRepository(DriveFile)
|
@EntityRepository(DriveFile)
|
||||||
export class DriveFileRepository extends Repository<DriveFile> {
|
export class DriveFileRepository extends Repository<DriveFile> {
|
||||||
public validateFileName(name: string): boolean {
|
public validateFileName(name: string): boolean {
|
||||||
|
@ -89,20 +95,19 @@ export class DriveFileRepository extends Repository<DriveFile> {
|
||||||
return parseInt(sum, 10) || 0;
|
return parseInt(sum, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async pack(src: DriveFile['id'], options?: PackOptions): Promise<PackedDriveFile | null>;
|
||||||
|
public async pack(src: DriveFile, options?: PackOptions): Promise<PackedDriveFile>;
|
||||||
public async pack(
|
public async pack(
|
||||||
src: DriveFile['id'] | DriveFile,
|
src: DriveFile['id'] | DriveFile,
|
||||||
options?: {
|
options?: PackOptions
|
||||||
detail?: boolean,
|
): Promise<PackedDriveFile | null> {
|
||||||
self?: boolean,
|
|
||||||
withUser?: boolean,
|
|
||||||
}
|
|
||||||
): Promise<PackedDriveFile> {
|
|
||||||
const opts = Object.assign({
|
const opts = Object.assign({
|
||||||
detail: false,
|
detail: false,
|
||||||
self: false
|
self: false
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
const file = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
const file = typeof src === 'object' ? src : await this.findOne(src);
|
||||||
|
if (file == null) return null;
|
||||||
|
|
||||||
const meta = await fetchMeta();
|
const meta = await fetchMeta();
|
||||||
|
|
||||||
|
@ -128,15 +133,12 @@ export class DriveFileRepository extends Repository<DriveFile> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public packMany(
|
public async packMany(
|
||||||
files: any[],
|
files: any[],
|
||||||
options?: {
|
options?: PackOptions
|
||||||
detail?: boolean
|
|
||||||
self?: boolean,
|
|
||||||
withUser?: boolean,
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
return Promise.all(files.map(f => this.pack(f, options)));
|
const items = await Promise.all(files.map(f => this.pack(f, options)));
|
||||||
|
return items.filter(x => x != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue