use of org.thoughtcrime.securesms.util.FileUtils in project Signal-Android by WhisperSystems.
the class DownloadLatestEmojiDataJob method clearOldEmojiData.
private static void clearOldEmojiData(@NonNull Context context, @Nullable EmojiFiles.Version newVersion) {
EmojiFiles.Version version = EmojiFiles.Version.readVersion(context);
final String currentDirectoryName;
final String newVersionDirectoryName;
if (version != null) {
currentDirectoryName = version.getUuid().toString();
} else {
currentDirectoryName = "";
}
if (newVersion != null) {
newVersionDirectoryName = newVersion.getUuid().toString();
} else {
newVersionDirectoryName = "";
}
File emojiDirectory = EmojiFiles.getBaseDirectory(context);
File[] files = emojiDirectory.listFiles();
if (files == null) {
Log.d(TAG, "No emoji data to delete.");
return;
}
Log.d(TAG, "Deleting old folders of emoji data");
Stream.of(files).filter(File::isDirectory).filterNot(file -> file.getName().equals(currentDirectoryName)).filterNot(file -> file.getName().equals(newVersionDirectoryName)).forEach(FileUtils::deleteDirectory);
EmojiPageCache.INSTANCE.clear();
if (version != null) {
SignalStore.emojiValues().clearJumboEmojiSheets(version.getVersion());
}
}
Aggregations