refactor: use storage repository stat instead of real stat

This commit is contained in:
izzy
2025-12-18 14:14:24 +00:00
parent 5028c56ad8
commit 098563ef4e
+6 -4
View File
@@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { createHash } from 'node:crypto'; import { createHash } from 'node:crypto';
import { createReadStream } from 'node:fs'; import { createReadStream } from 'node:fs';
import { stat } from 'node:fs/promises';
import { basename } from 'node:path'; import { basename } from 'node:path';
import { Readable, Writable } from 'node:stream'; import { Readable, Writable } from 'node:stream';
import { pipeline } from 'node:stream/promises'; import { pipeline } from 'node:stream/promises';
@@ -322,7 +321,8 @@ export class IntegrityService extends BaseService {
const results = await Promise.all( const results = await Promise.all(
items.map(({ reportId, path }) => items.map(({ reportId, path }) =>
stat(path) this.storageRepository
.stat(path)
.then(() => void 0) .then(() => void 0)
.catch(() => reportId), .catch(() => reportId),
), ),
@@ -388,7 +388,8 @@ export class IntegrityService extends BaseService {
const results = await Promise.all( const results = await Promise.all(
items.map((item) => items.map((item) =>
stat(item.path) this.storageRepository
.stat(item.path)
.then(() => ({ ...item, exists: true })) .then(() => ({ ...item, exists: true }))
.catch(() => ({ ...item, exists: false })), .catch(() => ({ ...item, exists: false })),
), ),
@@ -424,7 +425,8 @@ export class IntegrityService extends BaseService {
const results = await Promise.all( const results = await Promise.all(
paths.map(({ reportId, path }) => paths.map(({ reportId, path }) =>
stat(path) this.storageRepository
.stat(path)
.then(() => reportId) .then(() => reportId)
.catch(() => void 0), .catch(() => void 0),
), ),