|
978 | 978 | # Explicitly load the library, and do everything we can to hide any |
979 | 979 | # package startup messages (because we don't want to put non-JSON |
980 | 980 | # on stdout) |
981 | | - invisible(capture.output(suppressPackageStartupMessages(suppressWarnings( |
982 | | - success <- library(x, character.only = TRUE, quietly = TRUE, logical.return = TRUE) |
983 | | - )))) |
| 981 | + invisible(capture.output(suppressPackageStartupMessages(suppressWarnings({ |
| 982 | + |
| 983 | + ## Don't load the package if a corresponding 00LOCK directory exists. |
| 984 | + ## This gives partial protection against attempting to load a package |
| 985 | + ## while another R process is attempting to modify the library directory. |
| 986 | + has00LOCK <- FALSE |
| 987 | + for (libPath in .libPaths()) |
| 988 | + { |
| 989 | + globalLockPath <- file.path(libPath, "00LOCK") |
| 990 | + pkgLockPath <- file.path(libPath, paste("00LOCK", basename(x), sep = "-")) |
| 991 | + if (file.exists(globalLockPath) || file.exists(pkgLockPath)) |
| 992 | + { |
| 993 | + has00LOCK <- TRUE |
| 994 | + break |
| 995 | + } |
| 996 | + } |
| 997 | + |
| 998 | + success <- if (has00LOCK) |
| 999 | + FALSE |
| 1000 | + else |
| 1001 | + library(x, character.only = TRUE, quietly = TRUE, logical.return = TRUE) |
| 1002 | + |
| 1003 | + })))) |
984 | 1004 |
|
985 | 1005 | if (!success) |
986 | 1006 | return(.rs.emptyFunctionInfo()) |
987 | 1007 |
|
988 | | - # Get the exported items in the NAMESPACE (for search path + `::` |
989 | | - # completions). |
| 1008 | + # Get the exported items in the NAMESPACE |
| 1009 | + # (for search path + `::` completions). |
990 | 1010 | ns <- asNamespace(x) |
991 | 1011 | exports <- getNamespaceExports(ns) |
992 | 1012 | objects <- mget(exports, ns, inherits = TRUE) |
|
0 commit comments