Skip to content

Commit c9d77b2

Browse files
committed
fix error in printing of backup queue when dry run is activated
1 parent d8903f6 commit c9d77b2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

R/BackupQueue.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ BackupQueue <- R6::R6Class(
9999
dd,
100100
c(paste(nrow(dd), "files total"), sum(as.integer(dd[, "size"])))
101101
)
102-
dd[, "size"] <- pad_left(fmt_bytes(dd[, "size"]))
102+
103+
if (DRY_RUN$active){
104+
dd[, "size"] <- pad_left(fmt_bytes(dd[, "size"], na = "<dry run>"))
105+
} else {
106+
dd[, "size"] <- pad_left(fmt_bytes(dd[, "size"]))
107+
}
108+
109+
103110
dd[, "file"] <- pad_right(dd[, "file"])
104111
assert(nrow(dd) >= 3)
105112
sel <- 2:(nrow(dd) - 1)

R/utils.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@ first <- function(x){
1313

1414

1515
fmt_bytes <- function(
16-
x
16+
x,
17+
na = "<NA>"
1718
){
1819
x <- as.numeric(x)
1920

2021
readablifiy <- function(.x){
22+
if (is.na(.x) || is.null(.x)){
23+
return(na)
24+
}
25+
2126
for (unit in c("B", "KiB", "MiB", "GiB", "TiB")){
22-
if (max(abs(.x)) < 1024 || unit == "TiB")
27+
if (max(abs(.x), na.rm = TRUE) < 1024 || unit == "TiB")
2328
break
2429
else
2530
.x <- .x / 1024
2631
}
32+
2733
return(paste(round(.x, 1), unit))
2834
}
2935

0 commit comments

Comments
 (0)