Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 3c46c95

Browse files
committed
Code revision suggestions have been implemented.
1 parent f14abb0 commit 3c46c95

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ class CreateRemoteShareOperation(
126126
Timber.d("Successful response: $response")
127127
result.data = parseResponse(response!!)
128128
Timber.d("*** Creating new remote share operation completed ")
129-
return result
129+
130+
val emptyShare = result.data.shares.first()
131+
132+
return if (retrieveShareDetails) {
133+
// retrieve more info - PUT only returns the index of the new share
134+
GetRemoteShareOperation(emptyShare.id).execute(client)
135+
} else {
136+
result
137+
}
130138
}
131139

132-
private fun createFormBodyBuilder(): FormBody {
140+
private fun createFormBody(): FormBody {
133141

134142
val formBodyBuilder = FormBody.Builder()
135143
.add(PARAM_PATH, remoteFilePath)
@@ -164,7 +172,7 @@ class CreateRemoteShareOperation(
164172
override fun run(client: OwnCloudClient): RemoteOperationResult<ShareResponse> {
165173
val requestUri = buildRequestUri(client.baseUri)
166174

167-
val postMethod = PostMethod(URL(requestUri.toString()), createFormBodyBuilder()).apply {
175+
val postMethod = PostMethod(URL(requestUri.toString()), createFormBody()).apply {
168176
setRequestHeader(HttpConstants.CONTENT_TYPE_HEADER, HttpConstants.CONTENT_TYPE_URLENCODED_UTF8)
169177
addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
170178
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ class UpdateRemoteShareOperation
161161

162162
// Parameters to update
163163
if (name != null) {
164-
formBodyBuilder.add(PARAM_NAME, name!!)
164+
formBodyBuilder.add(PARAM_NAME, name.orEmpty())
165165
}
166166

167167
if (password != null) {
168-
formBodyBuilder.add(PARAM_PASSWORD, password!!)
168+
formBodyBuilder.add(PARAM_PASSWORD, password.orEmpty())
169169
}
170170

171171
if (expirationDateInMillis < INITIAL_EXPIRATION_DATE_IN_MILLIS) {

0 commit comments

Comments
 (0)