Check if system folders were renamed

pull/204/head
M66B 3 years ago
parent 31dcee9a2b
commit 44e62cfd57

@ -2040,6 +2040,30 @@ class Core {
" separator=" + separator +
" fetched in " + duration + " ms");
// Check if system folders were renamed
for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName();
if (TextUtils.isEmpty(fullName))
continue;
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attrs, fullName, false);
if (type != null &&
!EntityFolder.USER.equals(type) &&
!EntityFolder.SYSTEM.equals(type)) {
for (EntityFolder folder : local.values())
if (type.equals(folder.type) &&
!fullName.equals(folder.name) &&
!istore.getFolder(folder.name).exists()) {
Log.e(account.host +
" renaming " + type + " folder" +
" from " + folder.name + " to " + fullName);
folder.name = fullName;
db.folder().setFolderName(folder.id, fullName);
}
}
}
Map<String, EntityFolder> nameFolder = new HashMap<>();
Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
for (Folder ifolder : ifolders) {

@ -281,6 +281,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET inferiors = :inferiors WHERE id = :id AND NOT (inferiors IS :inferiors)")
int setFolderInferiors(long id, Boolean inferiors);
@Query("UPDATE folder SET name = :name WHERE id = :id AND NOT (name IS :name)")
int setFolderName(long id, String name);
@Query("UPDATE folder SET type = :type WHERE id = :id AND NOT (type IS :type)")
int setFolderType(long id, String type);

Loading…
Cancel
Save