@@ -6,23 +6,12 @@ use super::types::{
66 ConnectionTestResult , DiskSpaceInfo , InstallOptions , InstallProgress , ModelConfig ,
77 RemoteModelInfo ,
88} ;
9- use super :: { DATA_MIGRATOR_EXE , MAIN_APP_EXE } ;
9+ use super :: MAIN_APP_EXE ;
1010use openbitfun_core_types:: {
1111 installer_config_handoff:: {
1212 InstallerConfigHandoff , InstallerModelHandoff , INSTALLER_CONFIG_HANDOFF_FILE_NAME ,
1313 } ,
14- product_identity:: { data_namespace, hidden_data_directory, product_id} ,
15- } ;
16- #[ cfg( target_os = "windows" ) ]
17- use openbitfun_legacy_migration:: {
18- launch_trusted_executable, probe_legacy_source, HandoffStore , MigrationOnboardingStore ,
19- MigrationRoots , ProbeLimits , TrustedInstallationResolver ,
20- } ;
21- #[ cfg( target_os = "windows" ) ]
22- use openbitfun_product_domains:: legacy_migration:: {
23- MigrationPromptChoice , MigrationSelection , MigratorHandoffRequest ,
24- MigratorProtocolCapabilities , MigratorRequestMode , MigratorRequestOrigin ,
25- CURRENT_MIGRATION_FORMAT_VERSION ,
14+ product_identity:: { data_namespace, hidden_data_directory} ,
2615} ;
2716use openbitfun_services_core:: json_store:: JsonFileStore ;
2817use serde:: { Deserialize , Serialize } ;
@@ -33,8 +22,6 @@ use std::fs::File;
3322use std:: io:: { Cursor , Read } ;
3423use std:: path:: { Path , PathBuf } ;
3524use std:: sync:: LazyLock ;
36- #[ cfg( target_os = "windows" ) ]
37- use std:: time:: { SystemTime , UNIX_EPOCH } ;
3825use tauri:: { Emitter , Manager , Window } ;
3926
4027#[ cfg( target_os = "windows" ) ]
@@ -48,23 +35,15 @@ struct WindowsInstallState {
4835
4936const MIN_WINDOWS_APP_EXE_BYTES : u64 = 5 * 1024 * 1024 ;
5037const PAYLOAD_MANIFEST_FILE : & str = "payload-manifest.json" ;
51- const REQUIRED_PAYLOAD_FILES : [ & str ; 7 ] = [
38+ const REQUIRED_PAYLOAD_FILES : [ & str ; 6 ] = [
5239 MAIN_APP_EXE ,
53- DATA_MIGRATOR_EXE ,
5440 "frontend/dist/index.html" ,
5541 "mobile-web/dist/index.html" ,
5642 "resources/ext-host/extension-host.js" ,
5743 "resources/worker_host.js" ,
5844 "flashgrep/flashgrep-x86_64-pc-windows-msvc.exe" ,
5945] ;
6046const INSTALLER_STATE_FILE : & str = "installer-state.json" ;
61- #[ cfg( target_os = "windows" ) ]
62- const MIGRATOR_HANDOFF_LIFETIME_MS : i64 = 10 * 60 * 1000 ;
63- #[ cfg( target_os = "windows" ) ]
64- const RELEASE_CHANNEL : & str = match option_env ! ( "OPENBITFUN_RELEASE_CHANNEL" ) {
65- Some ( value) => value,
66- None => "stable" ,
67- } ;
6847const EMBEDDED_PAYLOAD_ZIP : & [ u8 ] =
6948 include_bytes ! ( concat!( env!( "OUT_DIR" ) , "/embedded_payload.zip" ) ) ;
7049
@@ -858,9 +837,7 @@ pub(crate) fn launch_application(install_path: String) -> Result<(), String> {
858837 Ok ( ( ) )
859838}
860839
861- /// Create an Installer-origin onboarding handoff and launch the installed
862- /// standalone Data Migrator. The Installer never reads or writes migrated
863- /// product data itself.
840+ /// Retain the old command as an explicit unsupported response for older clients.
864841#[ derive( Debug , Default , Deserialize ) ]
865842#[ serde( default , deny_unknown_fields, rename_all = "camelCase" ) ]
866843pub ( crate ) struct LaunchLegacyDataMigratorRequest { }
@@ -869,98 +846,8 @@ pub(crate) struct LaunchLegacyDataMigratorRequest {}
869846pub ( crate ) fn launch_legacy_data_migrator (
870847 request : LaunchLegacyDataMigratorRequest ,
871848) -> Result < bool , String > {
872- #[ cfg( not( target_os = "windows" ) ) ]
873- {
874- let _ = request;
875- return Err (
876- "Legacy data migration is not supported by this Installer platform." . to_string ( ) ,
877- ) ;
878- }
879-
880- #[ cfg( target_os = "windows" ) ]
881- {
882- let _ = request;
883- let roots = MigrationRoots :: resolve_current_user ( )
884- . map_err ( |_| "Could not resolve the current-user migration storage." . to_string ( ) ) ?;
885- let Some ( source) = probe_legacy_source ( & roots, ProbeLimits :: default ( ) )
886- . map_err ( |_| "Could not safely inspect older data." . to_string ( ) ) ?
887- else {
888- return Ok ( false ) ;
889- } ;
890- if !source. supported {
891- return Err (
892- "The discovered legacy data format is not supported by this Data Migrator."
893- . to_string ( ) ,
894- ) ;
895- }
896-
897- let now_ms = migration_now_ms ( ) ;
898- let capabilities = MigratorProtocolCapabilities :: current ( ) ;
899- let handoff = MigratorHandoffRequest {
900- protocol_version : capabilities. protocol_version ,
901- mode : MigratorRequestMode :: Onboarding ,
902- origin : MigratorRequestOrigin :: Installer ,
903- run_id : uuid:: Uuid :: new_v4 ( ) . to_string ( ) ,
904- nonce : uuid:: Uuid :: new_v4 ( ) . to_string ( ) ,
905- source_id : Some ( source. source_id . clone ( ) ) ,
906- source_fingerprint : Some ( source. source_fingerprint . clone ( ) ) ,
907- selection : MigrationSelection :: all ( ) ,
908- caller_process_id : std:: process:: id ( ) ,
909- product_id : product_id ( ) . to_string ( ) ,
910- release_channel : RELEASE_CHANNEL . to_string ( ) ,
911- created_at_ms : now_ms,
912- expires_at_ms : now_ms. saturating_add ( MIGRATOR_HANDOFF_LIFETIME_MS ) ,
913- required_capabilities : capabilities. capabilities ,
914- } ;
915- HandoffStore :: new ( roots. clone ( ) , product_id ( ) , RELEASE_CHANNEL )
916- . write_request ( & handoff, now_ms)
917- . map_err ( |_| "Could not create a safe Data Migrator handoff." . to_string ( ) ) ?;
918- MigrationOnboardingStore :: new ( roots)
919- . update ( |state| {
920- state. format_version = CURRENT_MIGRATION_FORMAT_VERSION ;
921- state. source_fingerprint = source. source_fingerprint . clone ( ) ;
922- state. detected_at_ms . get_or_insert ( now_ms) ;
923- state. choice = MigrationPromptChoice :: Unset ;
924- state. last_prompted_version = Some ( env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ) ;
925- state. run_id = Some ( handoff. run_id . clone ( ) ) ;
926- state. handled_run_id = None ;
927- } )
928- . map_err ( |_| "Could not persist the Data Migrator handoff state." . to_string ( ) ) ?;
929-
930- let registered_install_path = super :: registry:: read_existing_install_from_uninstall_registry ( )
931- . map ( |registration| registration. install_location )
932- . or_else ( super :: registry:: read_tauri_install_location)
933- . ok_or_else ( || {
934- "The registered OpenBitFun installation could not be found. Repair the installation before starting Data Migrator."
935- . to_string ( )
936- } ) ?;
937- let desktop = PathBuf :: from ( registered_install_path) . join ( MAIN_APP_EXE ) ;
938- let executable = TrustedInstallationResolver :: resolve_sibling (
939- & desktop,
940- MAIN_APP_EXE ,
941- DATA_MIGRATOR_EXE ,
942- )
943- . map_err ( |_| {
944- "The installed Data Migrator is missing or failed installation layout checks. Repair the OpenBitFun installation."
945- . to_string ( )
946- } ) ?;
947- launch_trusted_executable (
948- & executable,
949- & [ std:: ffi:: OsStr :: new ( handoff. run_id . as_str ( ) ) ] ,
950- )
951- . map_err ( |_| "Could not launch the installed Data Migrator." . to_string ( ) ) ?;
952- Ok ( true )
953- }
954- }
955-
956- #[ cfg( target_os = "windows" ) ]
957- fn migration_now_ms ( ) -> i64 {
958- SystemTime :: now ( )
959- . duration_since ( UNIX_EPOCH )
960- . unwrap_or_default ( )
961- . as_millis ( )
962- . try_into ( )
963- . unwrap_or ( i64:: MAX )
849+ let _ = request;
850+ Err ( "Data Migrator is distributed separately. Download and run OpenBitFun Data Migrator to import legacy data." . to_string ( ) )
964851}
965852
966853/// Close the installer window.
@@ -2005,6 +1892,13 @@ mod tests {
20051892 use std:: io:: { Cursor , Write } ;
20061893 use zip:: write:: FileOptions ;
20071894
1895+ #[ test]
1896+ fn legacy_migration_command_reports_the_independent_distribution ( ) {
1897+ let result =
1898+ super :: launch_legacy_data_migrator ( super :: LaunchLegacyDataMigratorRequest :: default ( ) ) ;
1899+ assert ! ( result. unwrap_err( ) . contains( "distributed separately" ) ) ;
1900+ }
1901+
20081902 #[ test]
20091903 fn language_alias_priority_is_descending_and_stable_for_equal_lengths ( ) {
20101904 let aliases = INSTALLER_APP_LANGUAGE_ALIASES_BY_PRIORITY . as_slice ( ) ;
0 commit comments