Implement background media ingestion and Pi deployment
Android / test-and-build (push) Canceled after 0s
Server / deployment-config (push) Canceled after 0s
Server / vulnerability-scan (push) Canceled after 0s

This commit is contained in:
Курнат Андрей
2026-07-15 22:58:03 +03:00
parent 8da166fb6b
commit e48e1e36a5
32 changed files with 825 additions and 76 deletions
@@ -23,4 +23,9 @@ data class AutomaticUploadsConfiguration(
val videoUploadsConfiguration: FolderBackUpConfiguration?
) {
fun areAutomaticUploadsDisabled() = pictureUploadsConfiguration == null && videoUploadsConfiguration == null
val sourcePaths: List<String>
get() = listOfNotNull(pictureUploadsConfiguration, videoUploadsConfiguration)
.flatMap { it.sourcePaths }
.distinct()
}
@@ -35,6 +35,13 @@ data class FolderBackUpConfiguration(
val isVideoUploads get() = name == videoUploadsName
val sourcePaths get() = parseSourcePaths(sourcePath)
/**
* Picture uploads are an ingest operation: the source is removed only after
* the upload worker has completed successfully. Video uploads keep their
* explicitly configured behavior.
*/
val effectiveBehavior get() = if (isPictureUploads) UploadBehavior.MOVE else behavior
companion object {
const val pictureUploadsName = "Picture uploads"
const val videoUploadsName = "Video uploads"
@@ -59,4 +59,39 @@ class FolderBackUpConfigurationTest {
assertEquals("$firstSourcePath\n$secondSourcePath", encodedSourcePaths)
}
@Test
fun `picture uploads always remove source after successful upload`() {
val configuration = folderBackUpConfiguration(
name = FolderBackUpConfiguration.pictureUploadsName,
behavior = UploadBehavior.COPY,
)
assertEquals(UploadBehavior.MOVE, configuration.effectiveBehavior)
}
@Test
fun `video uploads preserve configured behavior`() {
val configuration = folderBackUpConfiguration(
name = FolderBackUpConfiguration.videoUploadsName,
behavior = UploadBehavior.COPY,
)
assertEquals(UploadBehavior.COPY, configuration.effectiveBehavior)
}
private fun folderBackUpConfiguration(
name: String,
behavior: UploadBehavior,
) = FolderBackUpConfiguration(
accountName = "account",
behavior = behavior,
sourcePath = "content://source",
uploadPath = "/CameraUpload",
wifiOnly = false,
chargingOnly = false,
lastSyncTimestamp = 0,
name = name,
spaceId = null,
)
}