Merge pull request #4355 from vector-im/feature/adm/timeline-disk-usage

Reducing timeline disk usage
This commit is contained in:
Benoit Marty 2021-10-28 15:16:27 +02:00 committed by GitHub
commit c22d3fbedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

View File

@ -163,6 +163,7 @@ internal abstract class SessionModule {
@JvmStatic
@Provides
@SessionFilesDirectory
@SessionScope
fun providesFilesDir(@UserMd5 userMd5: String,
@SessionId sessionId: String,
context: Context): File {

View File

@ -39,8 +39,11 @@ internal class RoomSyncEphemeralTemporaryStoreFile @Inject constructor(
moshi: Moshi
) : RoomSyncEphemeralTemporaryStore {
private val workingDir = File(fileDirectory, "rr")
.also { it.mkdirs() }
private val workingDir: File by lazy {
File(fileDirectory, "rr").also {
it.mkdirs()
}
}
private val roomSyncEphemeralAdapter = moshi.adapter(RoomSyncEphemeral::class.java)

View File

@ -26,17 +26,15 @@ abstract class AbstractVoiceRecorder(
context: Context,
private val filenameExt: String
) : VoiceRecorder {
private val outputDirectory = File(context.cacheDir, "voice_records")
private val outputDirectory: File by lazy {
File(context.cacheDir, "voice_records").also {
it.mkdirs()
}
}
private var mediaRecorder: MediaRecorder? = null
private var outputFile: File? = null
init {
if (!outputDirectory.exists()) {
outputDirectory.mkdirs()
}
}
abstract fun setOutputFormat(mediaRecorder: MediaRecorder)
abstract fun convertFile(recordedFile: File?): File?

View File

@ -27,11 +27,9 @@ import javax.inject.Inject
class VoicePlayerHelper @Inject constructor(
context: Context
) {
private val outputDirectory = File(context.cacheDir, "voice_records")
init {
if (!outputDirectory.exists()) {
outputDirectory.mkdirs()
private val outputDirectory: File by lazy {
File(context.cacheDir, "voice_records").also {
it.mkdirs()
}
}