@tutao/node-mimimi 328.260224.0 → 331.260224.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tutao/node-mimimi",
3
- "version": "328.260224.0",
3
+ "version": "331.260224.0",
4
4
  "main": "./dist/binding.js",
5
5
  "types": "./dist/binding.d.ts",
6
6
  "napi": {
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "devDependencies": {
16
- "@tutao/otest": "328.260224.0",
16
+ "@tutao/otest": "331.260224.0",
17
17
  "@napi-rs/cli": "3.0.0-alpha.68",
18
18
  "typescript": "5.8.3",
19
19
  "zx": "8.6.1"
@@ -30,8 +30,8 @@
30
30
  "version": "napi version"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@tutao/node-mimimi-win32-x64-msvc": "328.260224.0",
34
- "@tutao/node-mimimi-linux-x64-gnu": "328.260224.0",
35
- "@tutao/node-mimimi-darwin-universal": "328.260224.0"
33
+ "@tutao/node-mimimi-win32-x64-msvc": "331.260224.0",
34
+ "@tutao/node-mimimi-linux-x64-gnu": "331.260224.0",
35
+ "@tutao/node-mimimi-darwin-universal": "331.260224.0"
36
36
  }
37
37
  }
@@ -10,16 +10,20 @@ pub enum ImportErrorKind {
10
10
  SdkError,
11
11
  /// No import feature on the server (it's disabled)
12
12
  ImportFeatureDisabled,
13
- /// Blob responded with empty server url list
13
+ /// Blob responded with an empty server url list
14
14
  EmptyBlobServerList,
15
15
  /// Some mail was too big
16
16
  TooBigChunk,
17
- /// Error that occured when deleting a file
17
+ /// Error that occurred when deleting a file
18
18
  FileDeletionError,
19
19
  /// The import was finished, but some files
20
20
  /// were left behind and marked as failures.
21
21
  /// the path is the directory where the failures can be inspected
22
22
  SourceExhaustedSomeError,
23
+ /// This is returned when the server canceled an
24
+ /// ongoing import because the target MailSet is
25
+ /// deleted, and we therefore cannot continue the import.
26
+ ImportTargetFolderDeleted,
23
27
  }
24
28
 
25
29
  #[napi_derive::napi(string_enum)]
@@ -175,6 +179,12 @@ impl ImportErrorKind {
175
179
  ImportFailureReason::ImportDisabled,
176
180
  ))),
177
181
  };
182
+
183
+ pub const IMPORT_TARGET_FOLDER_DELETED: ApiCallError = ApiCallError::ServerResponseError {
184
+ source: HttpError::PreconditionFailedError(Some(ImportFailure(
185
+ ImportFailureReason::ImportTargetFolderDeleted,
186
+ ))),
187
+ };
178
188
  }
179
189
 
180
190
  impl MailImportErrorMessage {
@@ -184,6 +194,8 @@ impl MailImportErrorMessage {
184
194
 
185
195
  let kind = if error == ImportErrorKind::IMPORT_DISABLED_ERROR {
186
196
  ImportErrorKind::ImportFeatureDisabled
197
+ } else if error == ImportErrorKind::IMPORT_TARGET_FOLDER_DELETED {
198
+ ImportErrorKind::ImportTargetFolderDeleted
187
199
  } else {
188
200
  ImportErrorKind::SdkError
189
201
  };
package/src/importer.rs CHANGED
@@ -18,6 +18,7 @@ use crate::importer::attachment_importer::PerChunkAttachmentImporter;
18
18
  use crate::importer::messages::{
19
19
  ImportErrorKind, ImportOkKind, MailImportErrorMessage, PreparationError,
20
20
  };
21
+ use crate::importer::ImportStatus::Canceled;
21
22
  use crate::importer_api::TutaCredentials;
22
23
  use tutasdk::bindings::native_file_client::NativeFileClient;
23
24
  use tutasdk::entities::generated::tutanota::{
@@ -131,7 +132,7 @@ impl ImportEssential {
131
132
  }
132
133
 
133
134
  /// updates the remote importMailState, if changes to importMailState are valid
134
- /// @params updater: function updating the importMailState internally,
135
+ /// @params updater: function updating the importMailState internally
135
136
  /// and returning whether if it should be uploaded or not.
136
137
  pub(super) async fn update_remote_state(
137
138
  &self,
@@ -202,7 +203,6 @@ impl ImportEssential {
202
203
  ) -> Result<ImportMailPostOut, MailImportErrorMessage> {
203
204
  let server_to_upload = self.get_server_url_to_upload().await?;
204
205
  let import_mail_post_in = import_mail_data;
205
-
206
206
  self.logged_in_sdk
207
207
  .get_service_executor()
208
208
  .post::<ImportMailService>(
@@ -384,8 +384,7 @@ impl Importer {
384
384
  })?;
385
385
 
386
386
  // Import cannot be resumed if it was already cancelled or finished.
387
- let import_is_cancelled_or_finished = remote_import_state.status
388
- == ImportStatus::Canceled as i64
387
+ let import_is_cancelled_or_finished = remote_import_state.status == Canceled as i64
389
388
  || remote_import_state.status == ImportStatus::Finished as i64;
390
389
  if import_is_cancelled_or_finished {
391
390
  return Err(PreparationError::FinalisedImportCannotBeResumed);
@@ -651,7 +650,7 @@ impl Importer {
651
650
  ) -> Result<(), MailImportErrorMessage> {
652
651
  self.update_failed_mails_counter().await;
653
652
  match import_error.kind {
654
- // if the import is (temporary) disabled, we should give up and let user try again later
653
+ // if the import is (temporary) disabled, we should give up and let the user try again later
655
654
  ImportErrorKind::ImportFeatureDisabled => Err(ImportErrorKind::ImportFeatureDisabled)?,
656
655
 
657
656
  // If a server does not give any available blob storage client (which we also use to make service call),
@@ -688,6 +687,10 @@ impl Importer {
688
687
  // this kind will not be created by import loop,
689
688
  // exists only to pass over to api
690
689
  ImportErrorKind::SourceExhaustedSomeError => unreachable!(),
690
+
691
+ ImportErrorKind::ImportTargetFolderDeleted => {
692
+ Err(ImportErrorKind::ImportTargetFolderDeleted)?
693
+ },
691
694
  }
692
695
  }
693
696
 
@@ -700,7 +703,7 @@ impl Importer {
700
703
  self.essentials
701
704
  .update_remote_state(|remote_state| {
702
705
  match Importer::get_failed_mails_count(&self.essentials.import_directory) {
703
- Ok(failed_mail_count) => {
706
+ Ok(failed_mail_count) if remote_state.failedMails != failed_mail_count as i64 => {
704
707
  remote_state.failedMails = failed_mail_count as i64;
705
708
  true
706
709
  }
@@ -708,6 +711,7 @@ impl Importer {
708
711
  log::error!("Not incrementing failedMails on import state. Can not count failed emails: {e:?}");
709
712
  false
710
713
  }
714
+ _ => false,
711
715
  }
712
716
  })
713
717
  .await