fix: storage template failure after re-upload and previous fail (#16611)

fix: storage template breaks when files are re-uploaded after a move failure
This commit is contained in:
Zack Pollard
2025-03-05 15:00:37 +00:00
committed by GitHub
parent 3f4bbab4eb
commit 9922c8de59
6 changed files with 81 additions and 3 deletions

View File

@@ -152,6 +152,7 @@ export class StorageTemplateService extends BaseService {
this.logger.log('Storage template migration disabled, skipping');
return JobStatus.SKIPPED;
}
await this.moveRepository.cleanMoveHistory();
const assetPagination = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) =>
this.assetRepository.getAll(pagination, { withExif: true, withArchived: true }),
);
@@ -175,6 +176,12 @@ export class StorageTemplateService extends BaseService {
return JobStatus.SUCCESS;
}
@OnEvent({ name: 'asset.delete' })
async handleMoveHistoryCleanup({ assetId }: ArgOf<'asset.delete'>) {
this.logger.debug(`Cleaning up move history for asset ${assetId}`);
await this.moveRepository.cleanMoveHistorySingle(assetId);
}
async moveAsset(asset: AssetEntity, metadata: MoveAssetMetadata) {
if (asset.isExternal || StorageCore.isAndroidMotionPath(asset.originalPath)) {
// External assets are not affected by storage template