I thought up some ideas for "relative" locaDiskConn and I went to test the non-relative version (that is standard Trelliscope use-cases), and I made a piece of code that works and I don't understand why... maybe you can shed some light on it?
data(iris)
tmp1 = tempfile(tmpdir="/tmp")
tmp2 = tempfile(tmpdir="/tmp")
conn1 = vdbConn(tmp1, autoYes = TRUE)
ldisk_path = file.path(conn1$path, "data", "local_ddo")
dir.create(ldisk_path, recursive = TRUE)
ldisk = localDiskConn(ldisk_path,autoYes=TRUE)
kvmem = divide(iris, by="Species")
ldmem = convert(kvmem, ldisk)
panelFn = function(v) plot(v$Petal.Width, v$Petal.Length)
makeDisplay(ldmem, panelFn=panelFn, name="test", conn=conn1)
trelliscope::copy_dir(tmp1, tmp2)
unlink(tmp1, recursive=TRUE)
rm("ldmem")
rm("kvmem")
list.files(ldisk_path)
conn2 = vdbConn(tmp2, autoYes=TRUE)
list.files(conn2$path, recursive = TRUE)
view(conn=conn2) #<--- how is this working?
At this point I expected view(conn=conn2) to fail to find the ldmem since it is just a copy of conn1, but it doesn't it makes normal looking plots and I am not sure why? The spirit of the question is there anything in Trelliscope Viewer code that is fixing this up? I need to understand that before I can move on to my idea for relative path DDOs.
I inspected the disolayObj.Rdata and it does this:
> e = new.env()
> load(file.path(conn2$path, "displays", "common", "test", "displayObj.Rdata"), envir = e)
> str(e$displayObj)
List of 21
$ name : chr "test"
$ group : chr "common"
$ desc : chr ""
$ mdDesc : NULL
$ preRender : logi FALSE
$ panelFn :function (v)
..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 11 1 57 11 57 1 1
.. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x1f9fb36a0>
..- attr(*, "class")= chr [1:2] "function" "rplotFn"
$ panelFnType : chr "rplotFn"
$ panelDataSource:
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file '/private/tmp/file4f2b78db6436/data/local_ddo/4a7a45a288b320d14537ba28cfdb8db5.Rdata', probable reason 'No such file or directory'
Which is exactly what I expect! The question is why isn't that happening on view(conn=conn2)?