Merge pull request #4355 from vector-im/feature/adm/timeline-disk-usage
Reducing timeline disk usage
This commit is contained in:
commit
c22d3fbedc
|
@ -163,6 +163,7 @@ internal abstract class SessionModule {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@SessionFilesDirectory
|
@SessionFilesDirectory
|
||||||
|
@SessionScope
|
||||||
fun providesFilesDir(@UserMd5 userMd5: String,
|
fun providesFilesDir(@UserMd5 userMd5: String,
|
||||||
@SessionId sessionId: String,
|
@SessionId sessionId: String,
|
||||||
context: Context): File {
|
context: Context): File {
|
||||||
|
|
|
@ -39,8 +39,11 @@ internal class RoomSyncEphemeralTemporaryStoreFile @Inject constructor(
|
||||||
moshi: Moshi
|
moshi: Moshi
|
||||||
) : RoomSyncEphemeralTemporaryStore {
|
) : RoomSyncEphemeralTemporaryStore {
|
||||||
|
|
||||||
private val workingDir = File(fileDirectory, "rr")
|
private val workingDir: File by lazy {
|
||||||
.also { it.mkdirs() }
|
File(fileDirectory, "rr").also {
|
||||||
|
it.mkdirs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val roomSyncEphemeralAdapter = moshi.adapter(RoomSyncEphemeral::class.java)
|
private val roomSyncEphemeralAdapter = moshi.adapter(RoomSyncEphemeral::class.java)
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,15 @@ abstract class AbstractVoiceRecorder(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val filenameExt: String
|
private val filenameExt: String
|
||||||
) : VoiceRecorder {
|
) : 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 mediaRecorder: MediaRecorder? = null
|
||||||
private var outputFile: File? = null
|
private var outputFile: File? = null
|
||||||
|
|
||||||
init {
|
|
||||||
if (!outputDirectory.exists()) {
|
|
||||||
outputDirectory.mkdirs()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract fun setOutputFormat(mediaRecorder: MediaRecorder)
|
abstract fun setOutputFormat(mediaRecorder: MediaRecorder)
|
||||||
abstract fun convertFile(recordedFile: File?): File?
|
abstract fun convertFile(recordedFile: File?): File?
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,9 @@ import javax.inject.Inject
|
||||||
class VoicePlayerHelper @Inject constructor(
|
class VoicePlayerHelper @Inject constructor(
|
||||||
context: Context
|
context: Context
|
||||||
) {
|
) {
|
||||||
private val outputDirectory = File(context.cacheDir, "voice_records")
|
private val outputDirectory: File by lazy {
|
||||||
|
File(context.cacheDir, "voice_records").also {
|
||||||
init {
|
it.mkdirs()
|
||||||
if (!outputDirectory.exists()) {
|
|
||||||
outputDirectory.mkdirs()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue