grimbough / rhdf5

Package providing an interface between HDF5 and R
http://bioconductor.org/packages/rhdf5
60 stars 21 forks source link

h5testFileLocking false negatives - fails in a directory without permissions #77

Open LTLA opened 3 years ago

LTLA commented 3 years ago
dir.create("things")

library(rhdf5)
B = array(seq(0.1,2.0,by=0.1),dim=c(5,2,2))
attr(B, "scale") <- "liter"
h5write(B, "things/stuff.h5","B")

Sys.chmod(paths="things/", mode="544")

# Everything works fine with file locking
h5ls("things/stuff.h5")
h5read("things/stuff.h5", "B") 

# But yet...
h5testFileLocking("things/")
## [1] FALSE
## Warning message:
## In file.remove(file) :
##   cannot remove file 'things//filed7661b820f0d', reason 'No such file or directory'

The most obvious problem is that there is an extraneous warning when the file cannot be created. The less obvious problem is that file locking still seems to work when we don't have write access to the file, in which case rhdf5's check is not quite correct. Perhaps a better solution would be to test the file locking capability on a file-by-file basis prior to read operations.