Check if folder exists

pull/175/head
M66B 5 years ago
parent f5dc5f37e8
commit 1d7e5a10cc

@ -32,7 +32,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -364,9 +363,12 @@ public class FragmentGmail extends FragmentBase {
// Create folders // Create folders
for (EntityFolder folder : folders) { for (EntityFolder folder : folders) {
folder.account = account.id; EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
folder.id = db.folder().insertFolder(folder); if (existing == null) {
EntityLog.log(context, "Gmail folder=" + folder.name + " type=" + folder.type); folder.account = account.id;
folder.id = db.folder().insertFolder(folder);
EntityLog.log(context, "Gmail folder=" + folder.name + " type=" + folder.type);
}
} }
// Set swipe left/right folder // Set swipe left/right folder

@ -28,7 +28,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair; import android.util.Pair;
import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -527,9 +526,12 @@ public class FragmentOAuth extends FragmentBase {
// Create folders // Create folders
for (EntityFolder folder : folders) { for (EntityFolder folder : folders) {
folder.account = account.id; EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
folder.id = db.folder().insertFolder(folder); if (existing == null) {
EntityLog.log(context, "OAuth folder=" + folder.name + " type=" + folder.type); folder.account = account.id;
folder.id = db.folder().insertFolder(folder);
EntityLog.log(context, "OAuth folder=" + folder.name + " type=" + folder.type);
}
} }
// Set swipe left/right folder // Set swipe left/right folder

@ -28,7 +28,6 @@ import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -355,9 +354,12 @@ public class FragmentQuickSetup extends FragmentBase {
// Create folders // Create folders
for (EntityFolder folder : folders) { for (EntityFolder folder : folders) {
folder.account = account.id; EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
folder.id = db.folder().insertFolder(folder); if (existing == null) {
EntityLog.log(context, "Quick added folder=" + folder.name + " type=" + folder.type); folder.account = account.id;
folder.id = db.folder().insertFolder(folder);
EntityLog.log(context, "Quick added folder=" + folder.name + " type=" + folder.type);
}
} }
// Set swipe left/right folder // Set swipe left/right folder

Loading…
Cancel
Save