Fixed folder synchronization

pull/147/head
M66B 6 years ago
parent 086e2ea6ff
commit 0cb5b3e074

@ -198,7 +198,7 @@ public interface DaoFolder {
@Query("UPDATE folder SET last_sync = :last_sync WHERE id = :id")
int setFolderSync(long id, long last_sync);
@Query("UPDATE folder SET tbc = 0 WHERE id = :id")
@Query("UPDATE folder SET tbc = null WHERE id = :id")
int resetFolderTbc(long id);
@Query("UPDATE folder SET tbd = 1 WHERE id = :id")

@ -2187,22 +2187,25 @@ public class ServiceSynchronize extends LifecycleService {
Log.i("Start sync folders account=" + account.name);
List<String> names = new ArrayList<>();
for (EntityFolder folder : db.folder().getFolders(account.id)) {
for (EntityFolder folder : db.folder().getFolders(account.id))
if (folder.tbc != null) {
Log.i(folder.name + " creating");
IMAPFolder ifolder = (IMAPFolder) istore.getFolder(folder.name);
ifolder.create(Folder.HOLDS_MESSAGES);
db.folder().resetFolderTbc(folder.id);
}
if (folder.tbd == null)
names.add(folder.name);
else {
try {
ifolder.create(Folder.HOLDS_MESSAGES);
db.folder().resetFolderTbc(folder.id);
} catch (Throwable ex) {
reportError(account, folder, ex);
db.folder().deleteFolder(folder.id);
}
} else if (folder.tbd != null) {
Log.i(folder.name + " deleting");
IMAPFolder ifolder = (IMAPFolder) istore.getFolder(folder.name);
if (ifolder.exists())
ifolder.delete(false);
db.folder().deleteFolder(folder.id);
}
}
} else
names.add(folder.name);
Log.i("Local folder count=" + names.size());
Folder defaultFolder = istore.getDefaultFolder();

Loading…
Cancel
Save