mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
async hash extracted video
This commit is contained in:
parent
a185e06399
commit
9771c8aec1
@ -579,7 +579,7 @@ describe(MetadataService.name, () => {
|
|||||||
EmbeddedVideoFile: new BinaryField(0, ''),
|
EmbeddedVideoFile: new BinaryField(0, ''),
|
||||||
EmbeddedVideoType: 'MotionPhoto_Data',
|
EmbeddedVideoType: 'MotionPhoto_Data',
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
||||||
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
@ -623,7 +623,7 @@ describe(MetadataService.name, () => {
|
|||||||
EmbeddedVideoFile: new BinaryField(0, ''),
|
EmbeddedVideoFile: new BinaryField(0, ''),
|
||||||
EmbeddedVideoType: 'MotionPhoto_Data',
|
EmbeddedVideoType: 'MotionPhoto_Data',
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
||||||
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
@ -668,7 +668,7 @@ describe(MetadataService.name, () => {
|
|||||||
MicroVideo: 1,
|
MicroVideo: 1,
|
||||||
MicroVideoOffset: 1,
|
MicroVideoOffset: 1,
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
||||||
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
mocks.crypto.randomUUID.mockReturnValue(fileStub.livePhotoMotion.uuid);
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
@ -713,7 +713,7 @@ describe(MetadataService.name, () => {
|
|||||||
MicroVideo: 1,
|
MicroVideo: 1,
|
||||||
MicroVideoOffset: 1,
|
MicroVideoOffset: 1,
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.create.mockImplementation(
|
mocks.asset.create.mockImplementation(
|
||||||
(asset) => Promise.resolve({ ...assetStub.livePhotoMotionAsset, ...asset }) as Promise<AssetEntity>,
|
(asset) => Promise.resolve({ ...assetStub.livePhotoMotionAsset, ...asset }) as Promise<AssetEntity>,
|
||||||
);
|
);
|
||||||
@ -739,7 +739,7 @@ describe(MetadataService.name, () => {
|
|||||||
MicroVideo: 1,
|
MicroVideo: 1,
|
||||||
MicroVideoOffset: 1,
|
MicroVideoOffset: 1,
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.getByChecksum.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
mocks.asset.getByChecksum.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
mocks.storage.readFile.mockResolvedValue(video);
|
mocks.storage.readFile.mockResolvedValue(video);
|
||||||
@ -761,7 +761,7 @@ describe(MetadataService.name, () => {
|
|||||||
MicroVideo: 1,
|
MicroVideo: 1,
|
||||||
MicroVideoOffset: 1,
|
MicroVideoOffset: 1,
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.getByChecksum.mockResolvedValue({ ...assetStub.livePhotoMotionAsset, isVisible: true });
|
mocks.asset.getByChecksum.mockResolvedValue({ ...assetStub.livePhotoMotionAsset, isVisible: true });
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
mocks.storage.readFile.mockResolvedValue(video);
|
mocks.storage.readFile.mockResolvedValue(video);
|
||||||
@ -787,7 +787,7 @@ describe(MetadataService.name, () => {
|
|||||||
MicroVideo: 1,
|
MicroVideo: 1,
|
||||||
MicroVideoOffset: 1,
|
MicroVideoOffset: 1,
|
||||||
});
|
});
|
||||||
mocks.crypto.hashSha1.mockReturnValue(randomBytes(512));
|
mocks.crypto.hashFile.mockResolvedValue(randomBytes(512));
|
||||||
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
mocks.asset.create.mockResolvedValue(assetStub.livePhotoMotionAsset);
|
||||||
const video = randomBytes(512);
|
const video = randomBytes(512);
|
||||||
mocks.storage.readFile.mockResolvedValue(video);
|
mocks.storage.readFile.mockResolvedValue(video);
|
||||||
|
@ -458,7 +458,7 @@ export class MetadataService extends BaseService {
|
|||||||
length,
|
length,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const checksum = this.cryptoRepository.hashSha1(video);
|
const checksum = await this.cryptoRepository.hashFile(video);
|
||||||
|
|
||||||
let motionAsset = await this.assetRepository.getByChecksum({
|
let motionAsset = await this.assetRepository.getByChecksum({
|
||||||
ownerId: asset.ownerId,
|
ownerId: asset.ownerId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user