Skip to content

Commit 20edb18

Browse files
committed
fixed exception in case of file not found
1 parent 8429e0e commit 20edb18

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cs3client/file.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
from .config import Config
22-
from .exceptions import AuthenticationException, FileLockedException
22+
from .exceptions import AuthenticationException, FileLockedException, NotFoundException
2323
from .cs3resource import Resource
2424
from .statuscodehandler import StatusCodeHandler
2525

@@ -226,6 +226,7 @@ def write_file(
226226
else:
227227
headers = {
228228
"Upload-Length": str(size),
229+
"Content-Length": str(size),
229230
"X-Reva-Transfer": protocol.token,
230231
**dict([auth_token]),
231232
"X-Lock-Id": lock_id,
@@ -318,7 +319,10 @@ def read_file(self, auth_token: tuple, resource: Resource, lock_id: Optional[str
318319
f'msg="Error downloading file from Reva" code="{fileget.status_code}" '
319320
f'reason="{status_msg}"'
320321
)
321-
raise IOError(fileget.reason)
322+
if fileget.status_code == http.client.NOTFOUND:
323+
raise NotFoundException
324+
else:
325+
raise IOError(fileget.reason)
322326
else:
323327
self._log.info(
324328
f'msg="File open for read" {resource.get_file_ref_str()} elapsedTimems="{(tend - tstart) * 1000:.1f}"'

0 commit comments

Comments
 (0)