Implement background media ingestion and Pi deployment
This commit is contained in:
+5
@@ -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()
|
||||
}
|
||||
|
||||
+7
@@ -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"
|
||||
|
||||
+35
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user