Split local/remote folder sync

This commit is contained in:
M66B 2019-04-04 18:18:13 +02:00
parent 2585b089a4
commit 971fa5f0ef
1 changed files with 16 additions and 12 deletions

View File

@ -653,10 +653,21 @@ class Core {
static void onSynchronizeFolders(Context context, EntityAccount account, Store istore, State state) throws MessagingException {
DB db = DB.getInstance(context);
try {
db.beginTransaction();
Log.i("Start sync folders account=" + account.name);
// Get remote folders
Folder defaultFolder = istore.getDefaultFolder();
char separator = defaultFolder.getSeparator();
EntityLog.log(context, account.name + " folder separator=" + separator);
Folder[] ifolders = defaultFolder.list("*");
Map<Folder, String[]> attrs = new HashMap<>();
for (Folder ifolder : ifolders)
attrs.put(ifolder, ((IMAPFolder) ifolder).getAttributes());
Log.i("Remote folder count=" + ifolders.length + " separator=" + separator);
db.beginTransaction();
List<String> names = new ArrayList<>();
for (EntityFolder folder : db.folder().getFolders(account.id))
if (folder.tbc != null) {
@ -675,22 +686,15 @@ class Core {
names.add(folder.name);
Log.i("Local folder count=" + names.size());
Folder defaultFolder = istore.getDefaultFolder();
char separator = defaultFolder.getSeparator();
EntityLog.log(context, account.name + " folder separator=" + separator);
Folder[] ifolders = defaultFolder.list("*");
Log.i("Remote folder count=" + ifolders.length + " separator=" + separator);
Map<String, EntityFolder> nameFolder = new HashMap<>();
Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName();
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attrs, fullName);
String[] attr = attrs.get(ifolder);
String type = EntityFolder.getType(attr, fullName);
EntityLog.log(context, account.name + ":" + fullName +
" attrs=" + TextUtils.join(" ", attrs) + " type=" + type);
" attrs=" + TextUtils.join(" ", attr) + " type=" + type);
if (type != null) {
names.remove(fullName);