Skip to content

Commit ac82efd

Browse files
authored
Issue 53043: labkey.webdav.downloadFolder to account for contextPath in file href paths (#117)
Rlabkey v3.4.3 has been published to CRAN
1 parent eb8455e commit ac82efd

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

Rlabkey/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rlabkey
22
Version: 3.4.3
3-
Date: 2025-03-21
3+
Date: 2025-05-12
44
Title: Data Exchange Between R and 'LabKey' Server
55
Authors@R: c(person(given = "Peter",
66
family = "Hussey",

Rlabkey/NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Changes in 3.4.3
22
o Bugfix to labkey.selectRows when group_concat based field has a NULL value. Related to github issue #112
33
o Update documentation for experiment.createRun to include an example of inserting run level properties
4+
o Issue 53043: labkey.webdav.downloadFolder to account for contextPath in file href paths
45

56
Changes in 3.4.2
67
o Add showProgressBar parameter to labkey.webdav.downloadFolder and labkey.webdav.get

Rlabkey/R/labkey.webdav.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,15 @@ labkey.webdav.doDownloadFolder <- function(localDir, baseUrl=NULL, folderPath, r
295295

296296
files <- labkey.webdav.listDir(baseUrl=baseUrl, folderPath=folderPath, fileSet=fileSet, remoteFilePath=remoteFilePath)
297297
for (file in files[["files"]]) {
298-
relativeToRemoteRoot <- sub(prefix, "", file[["href"]])
299-
relativeToDownloadStart <- sub(paste0(prefix, remoteFilePath), "", file[["href"]])
298+
# Issue 53043: the files list href includes the server contextPath, so trim that if available
299+
fileHref <- file[["href"]]
300+
prefixIndex <- regexpr(prefix, fileHref)
301+
if (prefixIndex > -1) {
302+
fileHref <- substr(fileHref, prefixIndex, nchar(fileHref))
303+
}
304+
305+
relativeToRemoteRoot <- sub(prefix, "", fileHref)
306+
relativeToDownloadStart <- sub(paste0(prefix, remoteFilePath), "", fileHref)
300307

301308
localPath <- file.path(localDir, relativeToDownloadStart)
302309
if (file[["isdirectory"]]) {
@@ -319,7 +326,7 @@ labkey.webdav.doDownloadFolder <- function(localDir, baseUrl=NULL, folderPath, r
319326

320327
labkey.webdav.doDownloadFolder(localDir=localPath, baseUrl=baseUrl, folderPath=folderPath, fileSet=fileSet, remoteFilePath=relativeToRemoteRoot, overwriteFiles=overwriteFiles, mergeFolders=mergeFolders, showProgressBar=showProgressBar)
321328
} else {
322-
url <- paste0(baseUrl, trimLeadingPath(file[["href"]]))
329+
url <- paste0(baseUrl, trimLeadingPath(fileHref))
323330

324331
logMessage(paste0("Downloading file: ", relativeToRemoteRoot))
325332
logMessage(paste0("to: ", localPath))

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ schema objects (\code{labkey.getSchema}).
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
2121
Version: \tab 3.4.2\cr
22-
Date: \tab 2025-03-12\cr
22+
Date: \tab 2025-05-12\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}

0 commit comments

Comments
 (0)