fix: undefined file stat

This commit is contained in:
monoid 2024-10-13 23:46:17 +09:00
parent 1e3701e37c
commit fe310459da

View File

@ -68,10 +68,9 @@ export const createDefaultClass = (type: string): ContentFileConstructor => {
async getMtime(): Promise<number> {
const oldStat = this.getStat();
if (oldStat !== undefined) return oldStat.mtimeMs;
await this.getHash();
const newStat = this.getStat();
if (newStat === undefined) throw new Error("stat is undefined");
return newStat.mtimeMs;
const stat = await promises.stat(this.path);
this.stat = stat;
return stat.mtimeMs;
}
};
return cons;