Skip to content

Commit 5d9e713

Browse files
committed
Fix FileHandle/FileIO for VFS
* (Might have accidentally deleted a commit while rebasing...?)
1 parent 8599690 commit 5d9e713

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

tiledb/cc/vfs.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class FileHandle {
5757
uri.c_str(), mode, &this->_fh));
5858
}
5959

60-
void close() { tiledb_vfs_close(_ctx.ptr().get(), this->_fh); }
60+
void close() {
61+
_ctx.handle_error(tiledb_vfs_close(_ctx.ptr().get(), this->_fh));
62+
}
6163

6264
py::bytes read(uint64_t offset, uint64_t nbytes) {
6365
py::array data = py::array(py::dtype::of<std::byte>(), nbytes);

tiledb/tests/test_libtiledb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3743,7 +3743,7 @@ def test_write_read(self):
37433743
fio.close()
37443744

37453745
# read from file that does not exist
3746-
with self.assertRaises(IOError):
3746+
with self.assertRaises(tiledb.TileDBError):
37473747
vfs.open(self.path("do_not_exist"), "rb")
37483748

37493749
def test_io(self):

tiledb/vfs.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,20 @@ def __init__(self, vfs: VFS, uri: str, mode: str = "rb"):
155155
}
156156
if mode not in str_to_vfs_mode:
157157
raise ValueError(f"invalid mode {mode}")
158-
self._mode = mode
159158

160-
self._fh = lt.FileHandle(
161-
self._vfs.ctx(), self._vfs, uri, str_to_vfs_mode[self._mode]
162-
)
159+
self._mode = mode
163160
self._offset = 0
164161
self._nbytes = 0
165162

166163
if self._mode == "rb":
167164
try:
168165
self._nbytes = vfs.file_size(uri)
169166
except:
170-
raise IOError(f"URI {uri} is not a valid file")
167+
raise lt.TileDBError(f"URI {uri} is not a valid file")
168+
169+
self._fh = lt.FileHandle(
170+
self._vfs.ctx(), self._vfs, uri, str_to_vfs_mode[self._mode]
171+
)
171172

172173
def __len__(self):
173174
return self._nbytes

0 commit comments

Comments
 (0)