Skip to content

Commit 7895180

Browse files
authored
Merge pull request #80 from tlnagy/tn/fix-mmap-reopening-bug
Fix crash when attempting to reopen a stream on mmap access
2 parents 9610f96 + 84f30cb commit 7895180

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OMETIFF"
22
uuid = "2d0ec36b-e807-5756-994b-45af29551fcf"
33
authors = ["Tamas Nagy <[email protected]>"]
4-
version = "0.3.10"
4+
version = "0.3.11"
55

66
[deps]
77
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"

src/mmap.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function Base.getindex(A::ReadonlyTiffDiskArray{Gray{T}, R, N1, N2}, i1::Int, i2
5454
# if the file isn't open, lets open a handle and update it
5555
if !isopen(ifd.file.io)
5656
path = ifd.file.filepath
57-
ifd.file.io = getstream(open(path), path)
57+
ifd.file.io = getstream(open(path))
5858
end
5959

6060
n_strips = length(ifd.strip_offsets)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ end
165165
@test all(img[1:10,1,1,1] .== img2[1:10,1,1,1])
166166
# file is read only and should throw an error if you try and modify it
167167
@test_throws ErrorException img[1:10,1,1,1] .= 1.0
168+
169+
# test reopening the file stream on access if closed
170+
close(s)
171+
@test img[10, 10, 2, 1] == img2[10, 10, 2, 1]
168172
end
169173
end
170174
end

0 commit comments

Comments
 (0)