feat: storage template file move hardening (#5917)

* fix: pgvecto.rs extension breaks typeorm schema:drop command

* fix: parse postgres bigints to javascript number types when selecting data

* feat: verify file size is the same as original asset after copying file for storage template job

* feat: allow disabling of storage template job, defaults to disabled for new instances

* fix: don't allow setting concurrency for storage template migration, can cause race conditions above 1

* feat: add checksum verification when file is copied for storage template job

* fix: extract metadata for assets that aren't visible on timeline
This commit is contained in:
Zack Pollard
2023-12-29 18:41:33 +00:00
committed by GitHub
parent 5f6bd4ae7e
commit 2e38fa73bf
36 changed files with 686 additions and 225 deletions
@@ -239,15 +239,6 @@ describe(MetadataService.name, () => {
expect(assetMock.save).not.toHaveBeenCalled();
});
it('should handle an asset with isVisible set to false', async () => {
assetMock.getByIds.mockResolvedValue([{ ...assetStub.image, isVisible: false }]);
await expect(sut.handleMetadataExtraction({ id: assetStub.image.id })).resolves.toBe(false);
expect(assetMock.getByIds).toHaveBeenCalledWith([assetStub.image.id]);
expect(assetMock.upsertExif).not.toHaveBeenCalled();
expect(assetMock.save).not.toHaveBeenCalled();
});
it('should handle a date in a sidecar file', async () => {
const originalDate = new Date('2023-11-21T16:13:17.517Z');
const sidecarDate = new Date('2022-01-01T00:00:00.000Z');
@@ -114,7 +114,14 @@ export class MetadataService {
@Inject(ISystemConfigRepository) configRepository: ISystemConfigRepository,
) {
this.configCore = SystemConfigCore.create(configRepository);
this.storageCore = StorageCore.create(assetRepository, moveRepository, personRepository, storageRepository);
this.storageCore = StorageCore.create(
assetRepository,
moveRepository,
personRepository,
cryptoRepository,
configRepository,
storageRepository,
);
}
async init() {
@@ -199,7 +206,7 @@ export class MetadataService {
async handleMetadataExtraction({ id }: IEntityJob) {
const [asset] = await this.assetRepository.getByIds([id]);
if (!asset || !asset.isVisible) {
if (!asset) {
return false;
}