-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathBinary.ts
49 lines (44 loc) · 1.22 KB
/
Binary.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Entity, EntityData } from './Entity.js';
import { EasyData, EntityUtil } from '../util/EntityUtil.js';
interface BinaryData extends EntityData {
binaryId: string;
category: string;
parent: string;
name: string;
isDir: boolean;
size: number;
date: string;
sourceUrl?: string;
ignoreDownloadStatuses?: number[];
}
export class Binary extends Entity {
binaryId: string;
category: string;
parent: string;
name: string;
isDir: boolean;
size: number;
date: string;
sourceUrl?: string;
ignoreDownloadStatuses?: number[];
constructor(data: BinaryData) {
super(data);
this.binaryId = data.binaryId;
this.category = data.category;
this.parent = data.parent;
this.name = data.name;
this.isDir = data.isDir;
this.size = data.size;
this.date = data.date;
this.sourceUrl = data.sourceUrl || '';
this.ignoreDownloadStatuses = data.ignoreDownloadStatuses;
}
get storePath() {
// e.g.: /binaries/node/v16.13.1/node-v16.13.1-x64.msi
return `/binaries/${this.category}${this.parent}${this.name}`;
}
static create(data: EasyData<BinaryData, 'binaryId'>): Binary {
const newData = EntityUtil.defaultData(data, 'binaryId');
return new Binary(newData);
}
}