Skip to content

Commit 5ba8f34

Browse files
committed
Fixed lock handling in write_file
1 parent 508c8fc commit 5ba8f34

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cs3client/file.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def touch_file(self, auth_token: tuple, resource: Resource) -> None:
170170
self._log.debug(f'msg="Invoked TouchFile" trace="{res.status.trace}"')
171171

172172
def write_file(
173-
self, auth_token: tuple, resource: Resource, content: Union[str, bytes], size: int,
174-
lock_md: tuple = ('', '')
173+
self, auth_token: tuple, resource: Resource, content: Union[str, bytes], size: int, lock_md: tuple = None
175174
) -> None:
176175
"""
177176
Write a file using the given userid as access token. The entire content is written
@@ -183,14 +182,16 @@ def write_file(
183182
:param resource: Resource to write content to
184183
:param content: content to write
185184
:param size: size of content (optional)
186-
:param lock_md: tuple (<app_name>, <lock_id>)
185+
:param lock_md: tuple (<app_name>, <lock_id>) (optional)
187186
:return: None (Success)
188187
:raises: FileLockedException (File is locked),
189188
:raises: AuthenticationException (Authentication failed)
190189
:raises: UnknownException (Unknown error)
191190
192191
"""
193-
app_name, lock_id = lock_md
192+
app_name = lock_id = ''
193+
if lock_md:
194+
app_name, lock_id = lock_md
194195
tstart = time.time()
195196
# prepare endpoint
196197
if size == -1:
@@ -228,7 +229,7 @@ def write_file(
228229
"X-Reva-Transfer": protocol.token,
229230
**dict([auth_token]),
230231
"X-Lock-Id": lock_id,
231-
"X-Lock_Holder": app_name,
232+
"X-Lock-Holder": app_name,
232233
}
233234
putres = requests.put(
234235
url=protocol.upload_endpoint,

0 commit comments

Comments
 (0)