Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Fix import queries (#2413)
Leendert de Borst21d165ac65a3
diff --git a/apps/web/src/i18n/locales/en.json b/apps/web/src/i18n/locales/en.jsonindex 08b91ec82..ff0505667 100644--- a/apps/web/src/i18n/locales/en.json+++ b/apps/web/src/i18n/locales/en.json@@ -1093,6 +1093,7 @@"DeleteAllLogosButton": "Delete all logos","DeleteAllLogosConfirmMessage": "This removes every stored logo from your vault and clears the logo on each credential. You can re-download them at any time. Continue?","DeleteAllLogosConfirmTitle": "Delete all logos?",+ "DeleteAllLogosSuccessMessage": "Removed the logo of {{0}} items.","EstimatedTotalDescription": "This is an approximation calculated from your local data.","EstimatedTotalTitle": "Estimated vault size","ItemCountLabel": "Items",@@ -1105,6 +1106,9 @@"RedownloadAllLogosButton": "Re-download all logos","RedownloadAllLogosConfirmMessage": "This re-fetches the favicon for every credential that has a website URL, replacing the existing logo. Depending on your vault size this may take a while. Continue?","RedownloadAllLogosConfirmTitle": "Re-download all logos?",+ "RedownloadAllLogosSuccessMessage": "Updated the logo of {{0}} items.",+ "ServerTotalDescription": "The exact size of your encrypted vault as stored on the server, including attachments and logos.",+ "ServerTotalTitle": "Vault size on server","TopAttachmentsDescription": "Top 10 largest file attachments. Remove the attachment if you no longer need it.","TopAttachmentsTitle": "Largest attachments","TopLogosDescription": "Top 10 largest service logos. Logos are reused for items with the same domain.",diff --git a/core/client/src/database/repositories/ImportExportRepository.ts b/core/client/src/database/repositories/ImportExportRepository.tsindex 527387abd..b7c62935b 100644--- a/core/client/src/database/repositories/ImportExportRepository.ts+++ b/core/client/src/database/repositories/ImportExportRepository.ts@@ -73,7 +73,7 @@ export class ImportExportRepository extends BaseRepository {const definitionsByKey = new Map(fieldDefinitions.map(definition => [scopedKey(definition.ManifestId, definition.Id), definition]));const fieldValueRows = yield* this.query<ChildRow & { Id: string; FieldKey: string | null; FieldDefinitionId: string | null; Value: string | null; Weight: number; CreatedAt: string; UpdatedAt: string }>(- 'SELECT fv.Id, fv.ItemId, fv.ManifestId, fv.FieldKey, fv.FieldDefinitionId, fv.Value, fv.Weight, fv.CreatedAt, fv.UpdatedAt FROM FieldValues fv INNER JOIN Items i ON i.Id = fv.ItemId AND i.ManifestId = fv.ManifestId WHERE fv.IsDeleted = 0 AND i.IsDeleted = 0 AND i.DeletedAt IS NULL ORDER BY fv.Weight'+ 'SELECT fv.Id, fv.ItemId, fv.ManifestId, fv.FieldKey, fv.FieldDefinitionId, fv.Value, fv.Weight, fv.CreatedAt, fv.UpdatedAt FROM FieldValues fv INNER JOIN Items i ON i.Id = fv.ItemId AND i.ManifestId = fv.ManifestId WHERE fv.IsDeleted = 0 AND i.IsDeleted = 0 AND i.DeletedAt IS NULL ORDER BY fv.Weight, fv.ValueIndex');const fieldValuesByItem = ImportExportRepository.groupByItem(fieldValueRows, (row): FieldValueEntity => ({Id: row.Id,@@ -265,7 +265,6 @@ export class ImportExportRepository extends BaseRepository {item.ItemType,item.LogoId,item.FolderId,- item.FolderId,manifestId,createdAt,updatedAt,@@ -274,13 +273,14 @@ export class ImportExportRepository extends BaseRepository {// Custom field definitions come before the values that reference them; each is written once.const writtenDefinitions = new Set<string>();+ // Values of one multi-value field are numbered in file order.+ const valueIndexes = new Map<string, number>();for (const fieldValue of item.FieldValues) {const definition = fieldValue.FieldDefinition;if (definition && !writtenDefinitions.has(definition.Id)) {writtenDefinitions.add(definition.Id);yield* this.execute(FieldDefinitionQueries.INSERT, [definition.Id,- item.Id,manifestId,definition.FieldType,definition.Label,@@ -295,15 +295,19 @@ export class ImportExportRepository extends BaseRepository {]);}+ const fieldIdentity = fieldValue.FieldDefinitionId ?? fieldValue.FieldKey ?? '';+ const valueIndex = valueIndexes.get(fieldIdentity) ?? 0;+ valueIndexes.set(fieldIdentity, valueIndex + 1);+yield* this.execute(FieldValueQueries.INSERT, [fieldValue.Id,item.Id,- item.Id,manifestId,fieldValue.FieldDefinitionId,fieldValue.FieldKey,fieldValue.Value ?? '',fieldValue.Weight,+ valueIndex,toStandardFormat(fieldValue.CreatedAt),toStandardFormat(fieldValue.UpdatedAt),0,@@ -319,7 +323,6 @@ export class ImportExportRepository extends BaseRepository {totpCode.Digits,totpCode.Period,item.Id,- item.Id,manifestId,toStandardFormat(totpCode.CreatedAt),toStandardFormat(totpCode.UpdatedAt),@@ -331,7 +334,6 @@ export class ImportExportRepository extends BaseRepository {yield* this.execute(PasskeyQueries.INSERT, [passkey.Id,item.Id,- item.Id,manifestId,passkey.RpId,passkey.UserHandle,@@ -352,7 +354,6 @@ export class ImportExportRepository extends BaseRepository {attachment.Filename,attachment.Blob,item.Id,- item.Id,manifestId,toStandardFormat(attachment.CreatedAt),toStandardFormat(attachment.UpdatedAt),