aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index bf4ffcd0a..ec3256b46 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1214,22 +1214,24 @@ public class XmppConnectionService extends Service {
Log.d(Config.LOGTAG, "Do not check for deleted files because service has been destroyed");
return;
}
- final List<String> deletedUuids = new ArrayList<>();
- final List<DatabaseBackend.FilePath> relativeFilePaths = databaseBackend.getAllNonDeletedFilePath();
- for (final DatabaseBackend.FilePath filePath : relativeFilePaths) {
+ final long start = SystemClock.elapsedRealtime();
+ final List<DatabaseBackend.FilePathInfo> relativeFilePaths = databaseBackend.getFilePathInfo();
+ final List<DatabaseBackend.FilePathInfo> changed = new ArrayList<>();
+ for (final DatabaseBackend.FilePathInfo filePath : relativeFilePaths) {
if (destroyed) {
Log.d(Config.LOGTAG, "Stop checking for deleted files because service has been destroyed");
return;
}
final File file = fileBackend.getFileForPath(filePath.path);
- if (!file.exists()) {
- deletedUuids.add(filePath.uuid.toString());
+ if (filePath.setFileDeleted(!file.exists())) {
+ changed.add(filePath);
}
}
- Log.d(Config.LOGTAG, "found " + deletedUuids.size() + " deleted files on start up. total=" + relativeFilePaths.size());
- if (deletedUuids.size() > 0) {
- databaseBackend.markFileAsDeleted(deletedUuids);
- markUuidsAsDeletedFiles(deletedUuids);
+ final long duration = SystemClock.elapsedRealtime() - start;
+ Log.d(Config.LOGTAG, "found " + changed.size() + " changed files on start up. total=" + relativeFilePaths.size() + ". (" + duration + "ms)");
+ if (changed.size() > 0) {
+ databaseBackend.markFilesAsChanged(changed);
+ markChangedFiles(changed);
}
}
@@ -1869,6 +1871,16 @@ public class XmppConnectionService extends Service {
}
}
+ private void markChangedFiles(List<DatabaseBackend.FilePathInfo> infos) {
+ boolean changed = false;
+ for (Conversation conversation : getConversations()) {
+ changed |= conversation.markAsChanged(infos);
+ }
+ if (changed) {
+ updateConversationUi();
+ }
+ }
+
public void populateWithOrderedConversations(final List<Conversation> list) {
populateWithOrderedConversations(list, true, true);
}