From 2bf19ddc87fdbb4161e765c28beea0f61965b289 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Wed, 9 Oct 2024 16:45:50 +0200 Subject: [PATCH 1/3] update Typos fixed, improved error handling. --- diesel_migrations/src/file_based_migrations.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/diesel_migrations/src/file_based_migrations.rs b/diesel_migrations/src/file_based_migrations.rs index 0be2850db038..3c2fb7059211 100644 --- a/diesel_migrations/src/file_based_migrations.rs +++ b/diesel_migrations/src/file_based_migrations.rs @@ -98,7 +98,7 @@ impl FileBasedMigrations { }) } - /// Create a new file based migration source by searching the migration diretcory + /// Create a new file based migration source by searching the migration directory /// /// This method looks in the current and all parent directories for a folder named /// `migrations` @@ -108,7 +108,7 @@ impl FileBasedMigrations { Self::find_migrations_directory_in_path(std::env::current_dir()?.as_path()) } - /// Create a new file based migration source by searching a give path for the migration + /// Create a new file based migration source by searching a given path for the migration /// directory /// /// This method looks in the passed directory and all parent directories for a folder @@ -162,8 +162,10 @@ struct SqlFileMigration { impl SqlFileMigration { fn from_path(path: &Path) -> Result { if migrations_internals::valid_sql_migration_directory(path) { + let metadata_path = path.join("metadata.toml"); let metadata = TomlMetadataWrapper( - TomlMetadata::read_from_file(&path.join("metadata.toml")).unwrap_or_default(), + TomlMetadata::read_from_file(&metadata_path) + .map_err(|e| MigrationError::from(e))? ); Ok(Self { base_path: path.to_path_buf(), From f3629b064d1cc8a83cda0260eaf1b7335673a9ab Mon Sep 17 00:00:00 2001 From: shray sharma Date: Wed, 9 Oct 2024 16:52:25 +0200 Subject: [PATCH 2/3] upd --- diesel_migrations/src/file_based_migrations.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/diesel_migrations/src/file_based_migrations.rs b/diesel_migrations/src/file_based_migrations.rs index 3c2fb7059211..ee7a7d15be85 100644 --- a/diesel_migrations/src/file_based_migrations.rs +++ b/diesel_migrations/src/file_based_migrations.rs @@ -162,10 +162,8 @@ struct SqlFileMigration { impl SqlFileMigration { fn from_path(path: &Path) -> Result { if migrations_internals::valid_sql_migration_directory(path) { - let metadata_path = path.join("metadata.toml"); let metadata = TomlMetadataWrapper( - TomlMetadata::read_from_file(&metadata_path) - .map_err(|e| MigrationError::from(e))? + TomlMetadata::read_from_file(&path.join("metadata.toml"))? ); Ok(Self { base_path: path.to_path_buf(), From 5e6c6ea8d2cd25c7ac72d1fceffaebdb7e711a95 Mon Sep 17 00:00:00 2001 From: shray sharma Date: Wed, 9 Oct 2024 17:15:06 +0200 Subject: [PATCH 3/3] code return, custom errors issue, typos only --- diesel_migrations/src/file_based_migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diesel_migrations/src/file_based_migrations.rs b/diesel_migrations/src/file_based_migrations.rs index ee7a7d15be85..43e451e462d9 100644 --- a/diesel_migrations/src/file_based_migrations.rs +++ b/diesel_migrations/src/file_based_migrations.rs @@ -163,7 +163,7 @@ impl SqlFileMigration { fn from_path(path: &Path) -> Result { if migrations_internals::valid_sql_migration_directory(path) { let metadata = TomlMetadataWrapper( - TomlMetadata::read_from_file(&path.join("metadata.toml"))? + TomlMetadata::read_from_file(&path.join("metadata.toml")).unwrap_or_default(), ); Ok(Self { base_path: path.to_path_buf(),