Shared folder fix (#90)
* fix methods for shared drive items * update news * add explanatory comment * keep all properties consistent
This commit is contained in:
Родитель
7caee82ef4
Коммит
fc48e6040a
1
NEWS.md
1
NEWS.md
|
@ -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
|
||||
}
|
||||
))
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче