From c671c1b9d953c58078f61b3813f922f826424a88 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 25 May 2019 16:32:08 +0200 Subject: [PATCH] Small improvement --- .../eu/faircode/email/ServiceSynchronize.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 8b22918b3c..1ee3c69c72 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -586,8 +586,11 @@ public class ServiceSynchronize extends LifecycleService { public void folderCreated(FolderEvent e) { try { wlFolder.acquire(); - Log.i("Folder created=" + e.getFolder().getFullName()); - reload(ServiceSynchronize.this, "folder created"); + + String name = e.getFolder().getFullName(); + Log.i("Folder created=" + name); + if (db.folder().getFolderByName(account.id, name) == null) + reload(ServiceSynchronize.this, "folder created"); } finally { wlFolder.release(); } @@ -597,14 +600,15 @@ public class ServiceSynchronize extends LifecycleService { public void folderRenamed(FolderEvent e) { try { wlFolder.acquire(); - Log.i("Folder renamed=" + e.getFolder().getFullName()); String old = e.getFolder().getFullName(); String name = e.getNewFolder().getFullName(); + Log.i("Folder renamed from=" + old + " to=" + name); + int count = db.folder().renameFolder(account.id, old, name); Log.i("Renamed to " + name + " count=" + count); - - reload(ServiceSynchronize.this, "folder renamed"); + if (count == 0) + reload(ServiceSynchronize.this, "folder renamed"); } finally { wlFolder.release(); } @@ -614,8 +618,11 @@ public class ServiceSynchronize extends LifecycleService { public void folderDeleted(FolderEvent e) { try { wlFolder.acquire(); - Log.i("Folder deleted=" + e.getFolder().getFullName()); - reload(ServiceSynchronize.this, "folder deleted"); + + String name = e.getFolder().getFullName(); + Log.i("Folder deleted=" + name); + if (db.folder().getFolderByName(account.id, name) != null) + reload(ServiceSynchronize.this, "folder deleted"); } finally { wlFolder.release(); }