-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement new Backend.save() method that can be re-tried
- Loading branch information
Showing
7 changed files
with
93 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/calyxos/seedvault/core/backends/BackendSaver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 The Calyx Institute | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.calyxos.seedvault.core.backends | ||
|
||
import java.io.OutputStream | ||
|
||
/** | ||
* Used to save data with [Backend]s. | ||
*/ | ||
public interface BackendSaver { | ||
/** | ||
* The number of bytes that will be saved or `null` if unknown. | ||
*/ | ||
public val size: Long | ||
|
||
/** | ||
* The SHA256 hash (in lower-case hex string representation) the bytes to be saved have, | ||
* or `null` if it isn't known. | ||
*/ | ||
public val sha256: String? | ||
|
||
/** | ||
* Called by the backend when it wants to save the data to the provided [outputStream]. | ||
* Can be called more than once, in case the backend encountered an error saving. | ||
* | ||
* @return the number of bytes saved. Should be equal to [size]. | ||
*/ | ||
public fun save(outputStream: OutputStream): Long | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters