Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add attachment toggle checkbox to vault import
Leendert de Borst0e59880f904b
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razorindex f651eff04..71ed45d5f 100644--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/Components/ImportServiceCard.razor@@ -193,6 +193,14 @@<span class="ml-2 text-sm text-gray-500 dark:text-gray-400">(@string.Format(Localizer["FoldersDetected"], DetectedFolderCount))</span></label>}+ @if (DetectedAttachmentCount > 0)+ {+ <label class="flex items-center">+ <input type="checkbox" @bind="ImportAttachments" class="form-checkbox h-4 w-4 text-primary-600 rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700">+ <span class="ml-2 text-gray-700 dark:text-gray-300">@Localizer["ImportAttachmentsLabel"]</span>+ <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">(@string.Format(Localizer["AttachmentsDetected"], DetectedAttachmentCount, FormatBytes(DetectedAttachmentsTotalSize)))</span>+ </label>+ }</div>}<div class="flex justify-end mt-6 space-x-2">@@ -338,6 +346,9 @@private bool ImportFolders { get; set; } = true;private int DetectedFolderCount { get; set; } = 0;private List<string> DetectedFolderPaths { get; set; } = new();+ private bool ImportAttachments { get; set; } = true;+ private int DetectedAttachmentCount { get; set; } = 0;+ private long DetectedAttachmentsTotalSize { get; set; } = 0;private bool IsExtractingFavicons { get; set; }private int FaviconExtractionProgress { get; set; }private int TotalFaviconsToExtract { get; set; }@@ -713,6 +724,16 @@folderNameToId = await CreateOrGetFolders();}+ // If the user opted out of importing attachments, strip them before conversion+ // so they don't end up persisted on the resulting items.+ if (!ImportAttachments)+ {+ foreach (var credential in ImportedCredentials)+ {+ credential.Attachments = null;+ }+ }+var items = BaseImporter.ConvertToItem(ImportedCredentials, folderNameToId);// Clear logo tracking for this import session@@ -1145,6 +1166,23 @@// Detect folders in the import (hierarchical)DetectedFolderPaths = CollectHierarchicalFolderPaths(ImportedCredentials);DetectedFolderCount = DetectedFolderPaths.Count;++ // Detect attachments in the import (count and total blob size)+ DetectedAttachmentCount = 0;+ DetectedAttachmentsTotalSize = 0;+ foreach (var credential in ImportedCredentials)+ {+ if (credential.Attachments == null)+ {+ continue;+ }++ foreach (var attachment in credential.Attachments)+ {+ DetectedAttachmentCount++;+ DetectedAttachmentsTotalSize += attachment.Blob?.LongLength ?? 0;+ }+ }}/// <summary>@@ -1265,4 +1303,26 @@IsExtractingFavicons = false;StateHasChanged();}++ /// <summary>+ /// Formats a byte count as a human-readable size string (e.g. "3.9 MB").+ /// </summary>+ /// <param name="bytes">The number of bytes.</param>+ /// <returns>The formatted size string.</returns>+ private static string FormatBytes(long bytes)+ {+ string[] units = { "B", "KB", "MB", "GB", "TB" };+ double size = bytes;+ int unitIndex = 0;++ while (size >= 1024 && unitIndex < units.Length - 1)+ {+ size /= 1024;+ unitIndex++;+ }++ return unitIndex == 0+ ? $"{size:0} {units[unitIndex]}"+ : string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.#} {1}", size, units[unitIndex]);+ }}diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resxindex d3d3a0059..64c1580ae 100644--- a/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Settings/ImportExport/ImportServiceCard.en.resx@@ -94,6 +94,14 @@<value>{0} folder(s) detected</value><comment>Info text showing number of folders detected in the import. {0} is the count</comment></data>+ <data name="ImportAttachmentsLabel" xml:space="preserve">+ <value>Import detected attachments</value>+ <comment>Checkbox label for importing file attachments detected in the source export</comment>+ </data>+ <data name="AttachmentsDetected" xml:space="preserve">+ <value>{0} attachment(s), {1}</value>+ <comment>Info text showing number of attachments detected and their total size. {0} is the count, {1} is the human-readable size (e.g. "3.9 MB")</comment>+ </data><data name="DuplicateCredentialsWarning" xml:space="preserve"><value>{0} duplicate credential(s) were found and will not be imported.</value><comment>Warning text when duplicate credentials are detected. {0} is the count</comment>