Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with digest function with files on network drive #13

Closed
zross opened this issue May 8, 2015 · 5 comments
Closed

Issue with digest function with files on network drive #13

zross opened this issue May 8, 2015 · 5 comments

Comments

@zross
Copy link

zross commented May 8, 2015

I'm getting an error running the digest() function on a file stored on a network drive from a Windows computer while no error occurs on the same file from the local drive.

So the following works perfectly and C is a local drive:

fname <- "C:/junk/all_sites.prj"
h2 <- digest(fname, algo="md5", file=TRUE)

With an identical file moved to a network drive I get an error:

fname <- "X:/junk/all_sites.prj"
h2 <- digest(fname, algo="md5", file=TRUE)
Error in digest(fname, algo = "md5", file = TRUE) : 
  The specified file is not readable: X:/junk/all_sites.prj

This is causing problems with the deployApp() function in Shiny and the document() function in devtools but report digest errors. I reported this to RStudio (thinking it was a Shiny issue).

It seems this may be due to the file.access function used by digest. The code:

file.access(fname, mode=4)

returns a 0 (success) using the local path and a -1 (failure) with the network path.

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
digest_0.6.4

@eddelbuettel
Copy link
Owner

Methinks that is an OS issue. We do nothing but opening and reading / writiing files. We don't even know whether the file is local or not. So in brief if this fails you may just have to work on a local file and (as needed) move it.

The help page for file.access mentions no issues related to network drives, so maybe you need to sort this out at your end?

@zross
Copy link
Author

zross commented May 8, 2015

Thanks for the quick response. As you suggest, I'll sort this out on my end.

@zross zross closed this as completed May 8, 2015
@marcelboldt
Copy link

I have the same problem... Seems Windows related: if I call the windows method _access directly I get the same result:

library(inline)
inc <- "
#include <io.h>
"

src <- "
int res;
res = _access( \"d:\\path\\file.txt\" ,4);
return(wrap(res));
"

acc <- cxxfunction(signature(),
               body=src, 
               includes=inc,
               plugin="Rcpp")
acc()

# 0 for my C: drive
# -1 for a network drive (file system shown by Windows 7: CSC-Cache), currently in offline mode

@eddelbuettel
Copy link
Owner

Still don't think this is my issue. "Doctor it hurts when I do this ..." -- just don't place the to-be-digested files on a network drive if the OS does not fully support it.

@caerbannogwhite
Copy link

caerbannogwhite commented Mar 13, 2023

Unfortunately, there are circumstances in which it is impossible (or strongly discouraged) to move or copy the data from the network drive (ie, when working with sensible data).
Since it's still possible to read the files with any other R library, my suggestion (for MD5) here is:

content <- readBin(p, n = 1000000, what="raw")
md5 <- digest::digest(content, serialize = FALSE, algo = "md5")

edit: solution improved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants