Browse code

Chore: Get rid of silent error in hsm migration

Thomas Cataldo authored on 09/01/2019 13:50:25
Showing 1 changed files
... ...
@@ -39,6 +39,7 @@ import net.bluemind.core.rest.ServerSideServiceProvider;
39 39
 import net.bluemind.core.task.service.IServerTaskMonitor;
40 40
 import net.bluemind.hsm.api.IHSM;
41 41
 import net.bluemind.hsm.api.Promote;
42
+import net.bluemind.hsm.api.TierChangeResult;
42 43
 import net.bluemind.imap.Flag;
43 44
 import net.bluemind.imap.FlagsList;
44 45
 import net.bluemind.imap.IMAPException;
... ...
@@ -82,7 +83,9 @@ public class MailboxHsmMigrationMaintenanceOperation extends MailboxMaintenanceO
82 83
 
83 84
 		if (!hsmCompleted(domainUid)) {
84 85
 			traverseFolders(mailbox, domainUid, monitor);
85
-			markAsFinished(domainUid);
86
+			if (repair) {
87
+				markAsFinished(domainUid);
88
+			}
86 89
 		}
87 90
 
88 91
 		monitor.progress(1, String.format("Mailbox %s HSM migration finished", mailboxToString(domainUid)));
... ...
@@ -186,7 +189,8 @@ public class MailboxHsmMigrationMaintenanceOperation extends MailboxMaintenanceO
186 189
 			logger.info("Promoting {} in folder {}", sum.getUid(), folder.uid);
187 190
 			Promote promote = summaryToPromote(sum, folder, mailbox.uid);
188 191
 			try {
189
-				hsm.promote(promote);
192
+				TierChangeResult result = hsm.promote(promote);
193
+				logger.info("{} / {} now has imap uid {}", sum.getUid(), result.hsmId, result.imapId);
190 194
 			} catch (ServerFault e) {
191 195
 				if (e.getCause() != null && e.getCause() instanceof IOException) {
192 196
 					logger.info("Cannot find archived eml for message {}:{}. Removing mail from spool", sum.getUid(),
... ...
@@ -197,6 +201,8 @@ public class MailboxHsmMigrationMaintenanceOperation extends MailboxMaintenanceO
197 201
 					List<Integer> asList = Arrays.asList((int) sum.getUid());
198 202
 					sc.uidStore(asList, fl, true);
199 203
 					sc.uidExpunge(asList);
204
+				} else {
205
+					logger.warn("Promote error for {}: {}", sum.getUid(), e.getMessage());
200 206
 				}
201 207
 			}
202 208
 		}