Skip to content

Commit a653e0b

Browse files
committed
Security reset and PP now clean up videos
1 parent 4d59810 commit a653e0b

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

app/src/main/kotlin/com/darkrockstudios/app/securecamera/camera/SecureImageRepository.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.darkrockstudios.app.securecamera.security.schemes.EncryptionScheme
1616
import com.darkrockstudios.app.securecamera.security.streaming.SecvFileFormat
1717
import com.darkrockstudios.app.securecamera.security.streaming.StreamingDecryptor
1818
import com.darkrockstudios.app.securecamera.security.streaming.StreamingEncryptionScheme
19+
import com.darkrockstudios.app.securecamera.security.streaming.VideoEncryptionHelper
1920
import kotlinx.coroutines.Dispatchers
2021
import kotlinx.coroutines.withContext
2122
import timber.log.Timber
@@ -42,19 +43,22 @@ class SecureImageRepository(
4243

4344
/**
4445
* Resets all security-related data when a security failure occurs.
45-
* Deletes all images and thumbnails and evicts all in-memory data.
46+
* Deletes all images, videos, temp files, thumbnails, and evicts all in-memory data.
4647
*/
4748
fun securityFailureReset() {
4849
deleteAllImages()
50+
deleteAllVideos()
4951
clearAllThumbnails()
5052
evictKey()
5153
}
5254

5355
/**
54-
* Deleted all images that haven't been flagged as benign
56+
* Deletes all images that haven't been flagged as benign, plus all videos.
57+
* Videos don't have a decoy system, so they are all deleted.
5558
*/
5659
fun activatePoisonPill() {
5760
deleteNonDecoyImages()
61+
deleteAllVideos()
5862
clearAllThumbnails()
5963
evictKey()
6064
}
@@ -533,6 +537,38 @@ class SecureImageRepository(
533537
return videos.map { deleteVideo(it) }.all { it }
534538
}
535539

540+
/**
541+
* Deletes all videos, including:
542+
* - Encrypted videos (.secv)
543+
* - Legacy unencrypted videos (.mp4)
544+
* - Temp recording files (temp_*.mp4)
545+
* - Partial encryption files (.encrypting)
546+
*/
547+
fun deleteAllVideos() {
548+
val videosDir = getVideosDirectory()
549+
if (!videosDir.exists()) {
550+
return
551+
}
552+
553+
// Delete all video-related files
554+
videosDir.listFiles()?.forEach { file ->
555+
if (file.isFile) {
556+
val name = file.name
557+
val shouldDelete = name.endsWith(".${SecvFileFormat.FILE_EXTENSION}") ||
558+
name.endsWith(".mp4") ||
559+
name.endsWith(VideoEncryptionHelper.ENCRYPTING_SUFFIX)
560+
561+
if (shouldDelete) {
562+
Timber.d("Deleting video file: $name")
563+
file.delete()
564+
}
565+
}
566+
}
567+
568+
// Clear video thumbnails from cache
569+
thumbnailCache.clear()
570+
}
571+
536572
/**
537573
* Deletes a media item (photo or video) based on its type.
538574
*/

0 commit comments

Comments
 (0)