* fix methods for shared drive items

* update news

* add explanatory comment

* keep all properties consistent
This commit is contained in:
Hong Ooi 2021-09-30 04:33:50 +10:00 коммит произвёл GitHub
Родитель 7caee82ef4
Коммит fc48e6040a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -1,5 +1,6 @@
# Microsoft365R 2.3.1.9000
- Fix broken methods for accessing items in shared OneDrive/SharePoint folders (#89).
- Fix a bug in sending file attachments in Teams chats (#87).
# Microsoft365R 2.3.1

Просмотреть файл

@ -207,7 +207,7 @@ public=list(
}
df$remoteItem <- lapply(seq_len(nrow(df)),
function(i) ms_drive_item$new(self$token, self$tenant, df$remoteItem[i, ]))
function(i) ms_drive_item$new(self$token, self$tenant, df$remoteItem[i, ], remote=TRUE))
switch(info,
partial=df[c("name", "size", "isdir", "remoteItem")],

Просмотреть файл

@ -108,9 +108,10 @@ ms_drive_item <- R6::R6Class("ms_drive_item", inherit=ms_object,
public=list(
initialize=function(token, tenant=NULL, properties=NULL)
initialize=function(token, tenant=NULL, properties=NULL, remote=FALSE)
{
self$type <- "drive item"
private$remote <- remote
private$api_type <- file.path("drives", properties$parentReference$driveId, "items")
super$initialize(token, tenant, properties)
},
@ -320,6 +321,9 @@ public=list(
private=list(
# flag: whether this object is a shared file/folder on another drive
remote=NULL,
# dest = . or '' --> this item
# dest = .. --> parent folder
# dest = (childname) --> path to named child
@ -327,14 +331,18 @@ private=list(
{
if(dest == ".")
dest <- ""
# this is needed to find the correct parent folder for a shared item
if(private$remote)
private$normalise_remote_item()
parent <- self$properties$parentReference
name <- self$properties$name
op <- if(name == "root")
file.path("drives", parent$driveId, "root:")
else
{
# have to infer the parent path if we got this item as a Teams channel folder
# in this case, assume the parent is the root folder
# null path means parent is the root folder
if(is.null(parent$path))
parent$path <- sprintf("/drives/%s/root:", parent$driveId)
if(dest != "..")
@ -356,6 +364,17 @@ private=list(
{
if(self$is_folder())
stop("This method is only applicable for a file item", call.=FALSE)
},
normalise_remote_item=function()
{
# if this was a shared item, replace properties with those obtained from original drive
if(!private$remote)
return(NULL)
parent <- self$properties$parentReference
op <- file.path("drives", parent$driveId, "items", self$properties$id)
self$properties <- call_graph_endpoint(self$token, op)
private$remote <- FALSE
}
))