Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RossanaTat committed Nov 4, 2024
1 parent 4e7288e commit 18515b8
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 30 deletions.
19 changes: 9 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,18 @@ left <- .syncdrenv$left
right <- .syncdrenv$right
# --- Compare synchronization status of the two directories --- #
# comparing by date of last modification
sync_status <- compare_directories(left_path = left,
right_path = right)
display_dir_tree(path_left = left,
path_right = right)
# --- Display synchronization status --- #
# visualize sync status in nice table -for example, of common files
display_sync_status(sync_status$common_files,
left_path = left,
right_path = right)
# comparing by date of last modification
compare_directories(left_path = left,
right_path = right)
# --- Perform synchronization action --- #
# asymmetric snchronization from left to right
#full_asym_sync_to_right(sync_status)
# asymmetric snchronization from left to right
full_asym_sync_to_right(left_path = left,
right_path = right,
force = FALSE)
```
199 changes: 179 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,78 @@ You can install the development version of syncdr from
``` r
# install.packages("devtools")
devtools::install_github("RossanaTat/syncdr")
#> Using github PAT from envvar GITHUB_PAT
#> Downloading GitHub repo RossanaTat/syncdr@HEAD
#> xfun (0.47 -> 0.49 ) [CRAN]
#> rlang (1.1.3 -> 1.1.4 ) [CRAN]
#> glue (1.7.0 -> 1.8.0 ) [CRAN]
#> cli (3.6.2 -> 3.6.3 ) [CRAN]
#> Rcpp (1.0.13 -> 1.0.13-1 ) [CRAN]
#> fastmap (1.1.1 -> 1.2.0 ) [CRAN]
#> digest (0.6.34 -> 0.6.37 ) [CRAN]
#> promises (1.2.1 -> 1.3.0 ) [CRAN]
#> fs (1.6.3 -> 1.6.5 ) [CRAN]
#> cachem (1.0.8 -> 1.1.0 ) [CRAN]
#> tinytex (0.52 -> 0.54 ) [CRAN]
#> evaluate (0.24.0 -> 1.0.1 ) [CRAN]
#> rmarkdown (2.28 -> 2.29 ) [CRAN]
#> collapse (15f2d3be7... -> 6f2515d4e...) [GitHub]
#> httpuv (1.6.14 -> 1.6.15 ) [CRAN]
#> rstudioapi (0.15.0 -> 0.17.1 ) [CRAN]
#> secretbase (1.0.1 -> 1.0.3 ) [CRAN]
#> Installing 16 packages: xfun, rlang, glue, cli, Rcpp, fastmap, digest, promises, fs, cachem, tinytex, evaluate, rmarkdown, httpuv, rstudioapi, secretbase
#> Installing packages into 'C:/Users/wb621604/AppData/Local/Temp/RtmpUff3hS/temp_libpath7df0176d6287'
#> (as 'lib' is unspecified)
#>
#> There is a binary version available but the source version is later:
#> binary source needs_compilation
#> rmarkdown 2.28 2.29 FALSE
#>
#> package 'xfun' successfully unpacked and MD5 sums checked
#> package 'rlang' successfully unpacked and MD5 sums checked
#> package 'glue' successfully unpacked and MD5 sums checked
#> package 'cli' successfully unpacked and MD5 sums checked
#> package 'Rcpp' successfully unpacked and MD5 sums checked
#> package 'fastmap' successfully unpacked and MD5 sums checked
#> package 'digest' successfully unpacked and MD5 sums checked
#> package 'promises' successfully unpacked and MD5 sums checked
#> package 'fs' successfully unpacked and MD5 sums checked
#> package 'cachem' successfully unpacked and MD5 sums checked
#> package 'tinytex' successfully unpacked and MD5 sums checked
#> package 'evaluate' successfully unpacked and MD5 sums checked
#> package 'httpuv' successfully unpacked and MD5 sums checked
#> package 'rstudioapi' successfully unpacked and MD5 sums checked
#> package 'secretbase' successfully unpacked and MD5 sums checked
#>
#> The downloaded binary packages are in
#> C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\downloaded_packages
#> installing the source package 'rmarkdown'
#> Downloading GitHub repo SebKrantz/collapse@HEAD
#>
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> checking for file 'C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\remotes796857ac340e\SebKrantz-collapse-6f2515d/DESCRIPTION' ... ✔ checking for file 'C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\remotes796857ac340e\SebKrantz-collapse-6f2515d/DESCRIPTION' (859ms)
#> ─ preparing 'collapse': (11.7s)
#> checking DESCRIPTION meta-information ... checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
#> ─ cleaning src
#> ─ checking for LF line-endings in source and make files and shell scripts (1.1s)
#> ─ checking for empty or unneeded directories (335ms)
#> ─ building 'collapse_2.0.17.tar.gz'
#>
#>
#> Installing package into 'C:/Users/wb621604/AppData/Local/Temp/RtmpUff3hS/temp_libpath7df0176d6287'
#> (as 'lib' is unspecified)
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> checking for file 'C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\remotes79681bb55ce6\RossanaTat-syncdr-653222f/DESCRIPTION' ... checking for file 'C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\remotes79681bb55ce6\RossanaTat-syncdr-653222f/DESCRIPTION' ... ✔ checking for file 'C:\Users\wb621604\AppData\Local\Temp\Rtmp4mcE3K\remotes79681bb55ce6\RossanaTat-syncdr-653222f/DESCRIPTION' (769ms)
#> ─ preparing 'syncdr': (11.2s)
#> checking DESCRIPTION meta-information ... checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
#> ─ checking for LF line-endings in source and make files and shell scripts (705ms)
#> ─ checking for empty or unneeded directories
#> Omitted 'LazyData' from DESCRIPTION
#> ─ building 'syncdr_0.0.2.9001.tar.gz'
#>
#>
#> Installing package into 'C:/Users/wb621604/AppData/Local/Temp/RtmpUff3hS/temp_libpath7df0176d6287'
#> (as 'lib' is unspecified)
```

## Usage example
Expand All @@ -44,32 +116,119 @@ library(syncdr)

# --- Create .syncdrenv --- #
.syncdrenv <- toy_dirs()
#> ■■■■■■■■■ 27% | ETA: 8s
#> ■■■■■■■■■■■■■■■■■■■ 60% | ETA: 5s
```

``` r
#> ■■■■■■■ 20% | ETA: 8s■■■■■■■■■■■■■■■ 47% | ETA: 5s■■■■■■■■■■■■■■■■■ 53% | ETA:
#> 5s■■■■■■■■■■■■■■■■■■■ 60% | ETA: 4s■■■■■■■■■■■■■■■■■■■■■■■■■■■ 87% | ETA: 1s
left <- .syncdrenv$left
right <- .syncdrenv$right

# --- Compare synchronization status of the two directories --- #
# comparing by date of last modification
sync_status <- compare_directories(left_path = left,
right_path = right)

# --- Display synchronization status --- #
# visualize sync status in nice table -for example, of common files
display_sync_status(sync_status$common_files,
left_path = left,
right_path = right)
```
display_dir_tree(path_left = left,
path_right = right)
#> (←)Left directory structure:
#> C:/Users/wb621604/AppData/Local/Temp/Rtmp4mcE3K/left
#> ├── A
#> │ ├── A1.Rds
#> │ ├── A2.Rds
#> │ └── A3.Rds
#> ├── B
#> │ ├── B1.Rds
#> │ ├── B2.Rds
#> │ └── B3.Rds
#> ├── C
#> │ ├── C1.Rds
#> │ ├── C2.Rds
#> │ └── C3.Rds
#> ├── D
#> │ ├── D1.Rds
#> │ └── D2.Rds
#> └── E
#> (→)Right directory structure:
#> C:/Users/wb621604/AppData/Local/Temp/Rtmp4mcE3K/right
#> ├── A
#> ├── B
#> │ ├── B1.Rds
#> │ └── B2.Rds
#> ├── C
#> │ ├── C1.Rds
#> │ ├── C1_duplicate.Rds
#> │ ├── C2.Rds
#> │ └── C3.Rds
#> ├── D
#> │ ├── D1.Rds
#> │ ├── D2.Rds
#> │ └── D3.Rds
#> └── E
#> ├── E1.Rds
#> ├── E2.Rds
#> └── E3.Rds

<div class="datatables html-widget html-fill-item" id="htmlwidget-66ae68e0399aa5849e19" style="width:100%;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-66ae68e0399aa5849e19">{"x":{"filter":"none","vertical":false,"data":[["1","2","3","4","5","6","7"],["/B/B1.Rds","/B/B2.Rds","/C/C1.Rds","/C/C2.Rds","/C/C3.Rds","/D/D1.Rds","/D/D2.Rds"],["/B/B1.Rds","/B/B2.Rds","/C/C1.Rds","/C/C2.Rds","/C/C3.Rds","/D/D1.Rds","/D/D2.Rds"],["2024-07-17T15:36:59Z","2024-07-17T15:37:02Z","2024-07-17T15:37:00Z","2024-07-17T15:37:03Z","2024-07-17T15:37:05Z","2024-07-17T15:37:02Z","2024-07-17T15:37:05Z"],["2024-07-17T15:37:00Z","2024-07-17T15:37:03Z","2024-07-17T15:37:06Z","2024-07-17T15:37:04Z","2024-07-17T15:37:06Z","2024-07-17T15:37:01Z","2024-07-17T15:37:04Z"],[false,false,false,false,false,true,true],[true,true,true,true,true,false,false],["older in left, newer in right dir","older in left, newer in right dir","older in left, newer in right dir","older in left, newer in right dir","older in left, newer in right dir","newer in left, older in right dir","newer in left, older in right dir"]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th> <\/th>\n <th>path_left<\/th>\n <th>path_right<\/th>\n <th>modification_time_left<\/th>\n <th>modification_time_right<\/th>\n <th>is_new_left<\/th>\n <th>is_new_right<\/th>\n <th>sync_status<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"pageLength":10,"columnDefs":[{"targets":[5,6],"createdCell":"function(td, cellData, rowData, row, col) {\n if (cellData === true) {\n $(td).css({'background-color': '#F8F4FF'});\n } else {\n $(td).css({'background-color': '#F0F8FF'});\n }\n }"},{"targets":7,"createdCell":"function(td, cellData, rowData, row, col) {\n if (cellData.includes('different content') ||\n cellData.includes('same date') ||\n cellData.includes('only in right')) {\n $(td).css({'background-color': '#a9def9'});\n } else {\n $(td).css({'background-color': '#e4c1f9'});\n }\n }"},{"orderable":false,"targets":0},{"name":" ","targets":0},{"name":"path_left","targets":1},{"name":"path_right","targets":2},{"name":"modification_time_left","targets":3},{"name":"modification_time_right","targets":4},{"name":"is_new_left","targets":5},{"name":"is_new_right","targets":6},{"name":"sync_status","targets":7}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":["options.columnDefs.0.createdCell","options.columnDefs.1.createdCell"],"jsHooks":[]}</script>

``` r
# comparing by date of last modification
compare_directories(left_path = left,
right_path = right)
#>
#> ── Synchronization Summary ─────────────────────────────────────────────────────
#> • Left Directory: 'C:/Users/wb621604/AppData/Local/Temp/Rtmp4mcE3K/left'
#> • Right Directory: 'C:/Users/wb621604/AppData/Local/Temp/Rtmp4mcE3K/right'
#> • Total Common Files: 7
#> • Total Non-common Files: 9
#> • Compare files by: date
#>
#> ── Common files ────────────────────────────────────────────────────────────────
#> path modification_time_left modification_time_right modified
#> 1 /left/B/B1.Rds 2024-11-04 15:09:19 2024-11-04 15:09:20 right
#> 2 /left/B/B2.Rds 2024-11-04 15:09:22 2024-11-04 15:09:23 right
#> 3 /left/C/C1.Rds 2024-11-04 15:09:20 2024-11-04 15:09:20 same date
#> 4 /left/C/C2.Rds 2024-11-04 15:09:23 2024-11-04 15:09:24 right
#> 5 /left/C/C3.Rds 2024-11-04 15:09:25 2024-11-04 15:09:26 right
#> 6 /left/D/D1.Rds 2024-11-04 15:09:22 2024-11-04 15:09:21 left
#> 7 /left/D/D2.Rds 2024-11-04 15:09:25 2024-11-04 15:09:24 left
#>
#> ── Non-common files ────────────────────────────────────────────────────────────
#>
#> ── Only in left ──
#> # A tibble: 4 × 1
#> path_left
#> <fs::path>
#> 1 /left/A/A1.Rds
#> 2 /left/A/A2.Rds
#> 3 /left/A/A3.Rds
#> 4 /left/B/B3.Rds
#> ── Only in right ──
#> # A tibble: 5 × 1
#> path_right
#> <fs::path>
#> 1 /right/C/C1_duplicate.Rds
#> 2 /right/D/D3.Rds
#> 3 /right/E/E1.Rds
#> 4 /right/E/E2.Rds
#> 5 /right/E/E3.Rds

# --- Perform synchronization action --- #

# asymmetric snchronization from left to right
#full_asym_sync_to_right(sync_status)
full_asym_sync_to_right(left_path = left,
right_path = right,
force = FALSE)
#> These files will be DELETED in right
#>
#> |Files |Action |
#> |:-------------------|:-------------|
#> |/C/C1_duplicate.Rds |To be deleted |
#> |/D/D3.Rds |To be deleted |
#> |/E/E1.Rds |To be deleted |
#> |/E/E2.Rds |To be deleted |
#> |/E/E3.Rds |To be deleted |
#> These files will be COPIED (overwriting if present) to right
#>
#>
#> |Files |Action |
#> |:---------|:------------|
#> |/D/D1.Rds |To be copied |
#> |/D/D2.Rds |To be copied |
#> |/A/A1.Rds |To be copied |
#> |/A/A2.Rds |To be copied |
#> |/A/A3.Rds |To be copied |
#> |/B/B3.Rds |To be copied |
#> Do you want to proceed? Type your answer (Yes/no/cancel)
#> ✔ synchronized
```

0 comments on commit 18515b8

Please sign in to comment.