4
4
5
5
drive_reveal_path <- function (x , ancestors = c(" none" , " parents" , " all" )) {
6
6
stopifnot(inherits(x , " dribble" ))
7
- if (no_file(x )) return (dribble_with_path())
7
+ if (no_file(x )) {
8
+ return (dribble_with_path())
9
+ }
8
10
ancestors <- ancestors %|| % dribble()
9
11
10
12
if (! inherits(ancestors , " dribble" )) {
@@ -48,7 +50,9 @@ sort_out_shared_drive_and_corpus <- function(x) {
48
50
drive_get_path <- function (path = NULL ,
49
51
shared_drive = NULL ,
50
52
corpus = NULL ) {
51
- if (length(path ) == 0 ) return (dribble_with_path())
53
+ if (length(path ) == 0 ) {
54
+ return (dribble_with_path())
55
+ }
52
56
stopifnot(is_path(path ))
53
57
path <- rootize_path(path )
54
58
@@ -125,7 +129,7 @@ get_immediate_parents <- function(x) {
125
129
resolve_paths <- function (d , folders = dribble()) {
126
130
probands <- pthize(d )
127
131
ancestors <- pthize(folders )
128
- raw_paths <- map(probands , ~ pth(list (.x ), ancestors ))
132
+ raw_paths <- map(probands , ~ pth(list (.x ), ancestors ))
129
133
pretty_paths <- map_chr(raw_paths , pathify )
130
134
put_column(d , nm = " path" , val = pretty_paths , .after = " name" )
131
135
}
@@ -146,16 +150,19 @@ pthize <- function(d) {
146
150
147
151
# turns the output of pth() (a list) into a filepath (a string)
148
152
pathify <- function (x ) {
149
- x <- map_if(x , ~ .x $ id == root_id(), ~ {.x $ name <- " ~" ; .x })
153
+ x <- map_if(x , ~ .x $ id == root_id(), ~ {
154
+ .x $ name <- " ~"
155
+ .x
156
+ })
150
157
151
158
last_mime_type <- pluck(last(x ), " mime_type" )
152
159
last_is_folder <- identical(last_mime_type , drive_mime_type(" folder" ))
153
160
last_is_folder_shortcut <-
154
161
identical(last_mime_type , drive_mime_type(" shortcut" )) &&
155
- identical(
156
- pluck(last(x ), " shortcut_details" , " targetMimeType" ),
157
- drive_mime_type(" folder" )
158
- )
162
+ identical(
163
+ pluck(last(x ), " shortcut_details" , " targetMimeType" ),
164
+ drive_mime_type(" folder" )
165
+ )
159
166
if (last_is_folder || last_is_folder_shortcut ) {
160
167
nm <- pluck(last(x ), " name" )
161
168
purrr :: pluck(x , length(x ), " name" ) <- append_slash(nm )
@@ -216,7 +223,9 @@ finalize <- function(dat, candidates) {
216
223
217
224
report_weird_stuff <- function (x , indicator , problem ) {
218
225
weird <- vec_slice(x , x [[" status" ]] == indicator )
219
- if (vec_size(weird ) == 0 ) return ()
226
+ if (vec_size(weird ) == 0 ) {
227
+ return ()
228
+ }
220
229
drive_bullets(c(
221
230
" !" = " Problem with {nrow(weird)} path{?s}: {problem}" ,
222
231
# these really should be sub-bullets, but not possible at this time
@@ -231,7 +240,8 @@ finalize <- function(dat, candidates) {
231
240
if (n_empty_string > 0 ) {
232
241
drive_bullets(c(
233
242
" !" = " Problem with {n_empty_string} path{?s}: \\
234
- path is empty string" ))
243
+ path is empty string"
244
+ ))
235
245
}
236
246
237
247
index <- unlist(scratch $ m )
@@ -280,7 +290,7 @@ get_by_name <- function(names, shared_drive = NULL, corpus = NULL) {
280
290
} else {
281
291
found <- drive_find(
282
292
q = or(q_clauses ),
283
- # fields = prep_fields(fields),
293
+ # fields = prep_fields(fields),
284
294
shared_drive = shared_drive , corpus = corpus
285
295
)
286
296
}
@@ -302,7 +312,7 @@ get_last_path_part <- function(path) {
302
312
# why? googledrive encourages the user to use a trailing slash to explicitly
303
313
# indicate a path that refers to a folder
304
314
slash_pos <- gregexpr(pattern = " /." , path )
305
- no_slash <- map_lgl(slash_pos , ~ all(.x == - 1 ))
315
+ no_slash <- map_lgl(slash_pos , ~ all(.x == - 1 ))
306
316
last_slash <- map_int(slash_pos , max )
307
317
ifelse(no_slash , path , substr(path , last_slash + 1 , nchar(path )))
308
318
}
0 commit comments