async hash extracted video

This commit is contained in:
mertalev 2025-02-28 10:48:53 +03:00
parent a185e06399
commit 9771c8aec1
No known key found for this signature in database
GPG Key ID: CA85EF6600C9E8AD
2 changed files with 8 additions and 8 deletions

View File

@ -579,7 +579,7 @@ describe(MetadataService.name, () => {
EmbeddedVideoFile: new BinaryField(0, ''),
EmbeddedVideoType: 'MotionPhoto_Data',
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
const video = randomBytes(512);
@ -623,7 +623,7 @@ describe(MetadataService.name, () => {
EmbeddedVideoFile: new BinaryField(0, ''),
EmbeddedVideoType: 'MotionPhoto_Data',
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
const video = randomBytes(512);
@ -668,7 +668,7 @@ describe(MetadataService.name, () => {
MicroVideo: 1,
MicroVideoOffset: 1,
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
const video = randomBytes(512);
@ -713,7 +713,7 @@ describe(MetadataService.name, () => {
MicroVideo: 1,
MicroVideoOffset: 1,
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.create.mockImplementation(
(asset) => Promise.resolve({ ...assetStub.livePhotoMotionAsset, ...asset }) as Promise<AssetEntity>,
);
@ -739,7 +739,7 @@ describe(MetadataService.name, () => {
MicroVideo: 1,
MicroVideoOffset: 1,
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.getByChecksum.mockResolvedValue(assetStub.livePhotoMotionAsset);
const video = randomBytes(512);
mocks.storage.readFile.mockResolvedValue(video);
@ -761,7 +761,7 @@ describe(MetadataService.name, () => {
MicroVideo: 1,
MicroVideoOffset: 1,
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.getByChecksum.mockResolvedValue({ ...assetStub.livePhotoMotionAsset, isVisible: true });
const video = randomBytes(512);
mocks.storage.readFile.mockResolvedValue(video);
@ -787,7 +787,7 @@ describe(MetadataService.name, () => {
MicroVideo: 1,
MicroVideoOffset: 1,
});
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
const video = randomBytes(512);
mocks.storage.readFile.mockResolvedValue(video);

View File

@ -458,7 +458,7 @@ export class MetadataService extends BaseService {
length,
});
}
const checksum = this.cryptoRepository.hashSha1(video);
const checksum = await this.cryptoRepository.hashFile(video);
let motionAsset = await this.assetRepository.getByChecksum({
ownerId: asset.ownerId,