Skip to content

Commit 8e37575

Browse files
authored
Issue 51606: labkey.webdav.downloadFolder to match file path prefix to the href values returned in listDir, which are URL encoded paths (#110)
- encode folderPath and remoteFilePath in labkey.webdav.doDownloadFolder - use the "href" instead of "id" for comparing paths for results of labkey.webdav.listDir
1 parent f855e59 commit 8e37575

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

Rlabkey/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rlabkey
2-
Version: 3.4.0
3-
Date: 2024-10-22
2+
Version: 3.4.1
3+
Date: 2024-11-08
44
Title: Data Exchange Between R and 'LabKey' Server
55
Authors@R: c(person(given = "Peter",
66
family = "Hussey",

Rlabkey/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Changes in 3.4.1
2+
o Issue 51606: labkey.webdav.downloadFolder to match file path prefix to the href values returned in listDir, which are URL encoded paths
3+
14
Changes in 3.4.0
25
o Issue 51160: update jsonEncodeRowsAndParams() to better handle decimal values for toJSON()
36

Rlabkey/R/labkey.webdav.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,19 @@ logMessage <- function(msg) {
279279

280280
labkey.webdav.doDownloadFolder <- function(localDir, baseUrl=NULL, folderPath, remoteFilePath, depth, overwriteFiles=TRUE, mergeFolders=TRUE, fileSet="@files")
281281
{
282-
# Note: this should use unencoded values to match the ID in JSON
283282
baseUrl <- normalizeSlash(baseUrl, leading = F, trailing = F)
284-
folderPath <- normalizeSlash(folderPath, leading = F)
283+
folderPath <- encodeFolderPath(folderPath);
285284
fileSet <- normalizeSlash(fileSet, leading = F, trailing = F)
286-
remoteFilePath <- normalizeSlash(remoteFilePath, leading = F)
285+
remoteFilePath <- normalizeSlash(encodeRemotePath(remoteFilePath), leading = F)
287286
localDir <- normalizeFolder(localDir)
288-
289-
prefix <- paste0("/_webdav/", folderPath, fileSet, '/')
290-
287+
288+
# Issue 51606: match file path prefix to the href values returned in listDir, which are URL encoded paths
289+
prefix <- paste0("/_webdav", folderPath, encodeRemotePath(fileSet), '/')
290+
291291
files <- labkey.webdav.listDir(baseUrl=baseUrl, folderPath=folderPath, fileSet=fileSet, remoteFilePath=remoteFilePath)
292292
for (file in files[["files"]]) {
293-
relativeToRemoteRoot <- sub(prefix, "", file[["id"]])
294-
relativeToDownloadStart <- sub(paste0(prefix, remoteFilePath), "", file[["id"]])
293+
relativeToRemoteRoot <- sub(prefix, "", file[["href"]])
294+
relativeToDownloadStart <- sub(paste0(prefix, remoteFilePath), "", file[["href"]])
295295

296296
localPath <- file.path(localDir, relativeToDownloadStart)
297297
if (file[["isdirectory"]]) {

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}).
1818
\tabular{ll}{
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
21-
Version: \tab 3.4.0\cr
22-
Date: \tab 2024-10-22\cr
21+
Version: \tab 3.4.1\cr
22+
Date: \tab 2024-11-08\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}

0 commit comments

Comments
 (0)