Skip to content

Commit

Permalink
Storage sdk: Remove parentId as paramater.
Browse files Browse the repository at this point in the history
  • Loading branch information
hans-hamel committed Jul 4, 2023
1 parent 8e36773 commit c5aa49b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ internal class GmsFileRepositoryImpl(

override fun open() = Unit

override fun updateFile(localFileToUpload: File, fileId: String, parentId: String?) = null
override fun updateFile(localFileToUpload: File, fileId: String) = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal class GmsFileRemoteDataSourceImpl(private val apiService: GoogleDriveAp
return response.toOmhFile()
}

override fun updateFile(localFileToUpload: File, fileId: String, parentId: String?) = null
override fun updateFile(localFileToUpload: File, fileId: String) = null

private fun getStringMimeTypeFromLocalFile(file: File) = MimeTypeMap
.getSingleton()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ internal class NonGmsFileRepositoryImpl(

override fun open() = Unit

override fun updateFile(localFileToUpload: File, fileId: String, parentId: String?) =
dataSource.updateFile(localFileToUpload, fileId, parentId)
override fun updateFile(localFileToUpload: File, fileId: String) =
dataSource.updateFile(localFileToUpload, fileId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ internal class NonGmsFileRemoteDataSourceImpl(private val retrofitImpl: GoogleRe
}
override fun updateFile(
localFileToUpload: File,
fileId: String,
parentId: String?
fileId: String
): OmhFile? {
val jsonMetaData = JSONObject().apply {
put(FILE_NAME_KEY, localFileToUpload.name)
put(FILE_PARENTS_KEY, parentId.isNullOrBlank())
}

val jsonRequestBody = jsonMetaData.toString().toRequestBody(JSON_MIME_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ abstract class OmhStorageClient protected constructor(
}
}

fun updateFile(
localFileToUpload: File,
fileId: String,
parentId: String?
): OmhTask<UpdateFileUseCaseResult> {
fun updateFile(localFileToUpload: File, fileId: String): OmhTask<UpdateFileUseCaseResult> {
val updateFileUseCase = UpdateFileUseCase(getRepository())
return OmhStorageTaskImpl {
val parameters = UpdateFileUseCaseParams(localFileToUpload, fileId, parentId)
val parameters = UpdateFileUseCaseParams(localFileToUpload, fileId)
val result = updateFileUseCase(parameters)
result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface OmhFileRemoteDataSource {

fun downloadFile(fileId: String, mimeType: String?): ByteArrayOutputStream

fun updateFile(localFileToUpload: File, fileId: String, parentId: String?): OmhFile?
fun updateFile(localFileToUpload: File, fileId: String): OmhFile?
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface OmhFileRepository {

fun open()

fun updateFile(localFileToUpload: File, fileId: String, parentId: String?): OmhFile?
fun updateFile(localFileToUpload: File, fileId: String): OmhFile?
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class UpdateFileUseCase(

override suspend fun execute(parameters: UpdateFileUseCaseParams): UpdateFileUseCaseResult {
return UpdateFileUseCaseResult(
repository.updateFile(parameters.localFileToUpdate, parameters.fileId, parameters.parentId)
repository.updateFile(parameters.localFileToUpdate, parameters.fileId)
)
}
}

data class UpdateFileUseCaseParams(val localFileToUpdate: File, val fileId: String, val parentId: String?)
data class UpdateFileUseCaseParams(val localFileToUpdate: File, val fileId: String)

data class UpdateFileUseCaseResult(val file: OmhFile?)

0 comments on commit c5aa49b

Please sign in to comment.