Learn R Programming

syncdr (version 0.1.1)

full_asym_sync_to_right: Full asymmetric synchronization to right directory

Description

This function performs a full asymmetric synchronization of the right directory based on the left directory. It includes the following synchronization steps (see Details below):

Usage

full_asym_sync_to_right(
  left_path = NULL,
  right_path = NULL,
  sync_status = NULL,
  by_date = TRUE,
  by_content = FALSE,
  recurse = TRUE,
  force = TRUE,
  delete_in_right = TRUE,
  backup = FALSE,
  backup_dir = "temp_dir",
  verbose = getOption("syncdr.verbose")
)

Value

Invisible TRUE indicating successful synchronization.

Arguments

left_path

Path to the left/first directory.

right_path

Path to the right/second directory.

sync_status

Object of class "syncdr_status", output of compare_directories().

by_date

Logical. If TRUE, synchronize based on file modification dates (default is TRUE).

by_content

Logical. If TRUE, synchronize based on file contents (default is FALSE).

recurse

Logical. If TRUE (default), files are copied to corresponding subdirectories in the destination folder. If FALSE, files are copied to the top level of the destination folder without creating subdirectories if they do not exist.

force

Logical. If TRUE (by default), directly perform synchronization of the directories. If FALSE, Displays a preview of actions and prompts the user for confirmation before proceeding. Synchronization is aborted if the user does not agree.

delete_in_right

Logical. If TRUE (default), files that exist only in the right directory (i.e., absent from the left directory) are deleted during synchronization. If FALSE, no files are removed from the right directory, even if they are exclusive to it.

backup

Logical. If TRUE, creates a backup of the right directory before synchronization. The backup is stored in the location specified by backup_dir.

backup_dir

Path to the directory where the backup of the original right directory will be stored. If not specified, the backup is stored in temporary directory (tempdir).

verbose

logical. If TRUE, display directory tree before and after synchronization. Default is FALSE

Details

  • For common files:

    • If comparing by date only (by_date = TRUE): Copy files that are newer in the left directory to the right directory.

    • If comparing by date and content (by_date = TRUE and by_content = TRUE): Copy files that are newer and different in the left directory to the right directory.

    • If comparing by content only (by_content = TRUE): Copy files that are different in the left directory to the right directory.

  • Copy to the right directory those files that exist only in the left directory.

  • Delete from the right directory those files that are exclusive in the right directory (i.e., missing in the left directory)

Examples

Run this code
# \donttest{
e <- toy_dirs(fast = TRUE)
left  <- e$left
right <- e$right
full_asym_sync_to_right(
  left_path  = left,
  right_path = right,
  by_date    = FALSE,
  by_content = TRUE
)
sync_status <- compare_directories(left_path = left, right_path = right)
full_asym_sync_to_right(sync_status = sync_status)
# }

Run the code above in your browser using DataLab