diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-01-27 12:43:19 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-01-27 12:43:19 +0100 |
commit | 30e6ac6324fa87d19b8e67252ceb5b2dddc2fd02 (patch) | |
tree | 5225b5ce8b6c991b7cf7dfb9dcc77baedc557f66 /src/main/java/de/pixart/messenger/services | |
parent | 9fa86472deb7df5b03c72a5bd2a7a3f87bf03c36 (diff) |
scan all files in case some files were previously marked as deleted by accident
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 30 |
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); } |