From 2e0e8ba994386ea99190fec887cdcb398356570c Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Sat, 21 Apr 2018 23:34:46 +0200 Subject: [PATCH] Add -p switch --- gcp | 19 ++++++++++++++----- gcp.1 | 7 +++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gcp b/gcp index a8d2075..9ed8fd1 100755 --- a/gcp +++ b/gcp @@ -72,6 +72,7 @@ const_DBUS_INTERFACE = "org.goffi.gcp" const_DBUS_PATH = "/org/goffi/gcp" const_BUFF_SIZE = 4096 const_PRESERVE = set(['mode','ownership','timestamps']) +const_PRESERVE_p = 'mode,ownership,timestamps' const_FS_FIX = set(['auto','force','no']) const_FILES_DIR = "~/.gcp" const_JOURNAL_PATH = const_FILES_DIR + "/journal" @@ -559,6 +560,10 @@ class GCP(): action="store_true", default=False, help=_("force overwriting of existing files") ) + parser.add_argument("-p", + action="store_true", default=False, + help=_("same as --preserve=%s" % const_PRESERVE_p) + ) parser.add_argument("--preserve", action="store", default='', help=_("preserve the specified attributes") @@ -641,18 +646,22 @@ class GCP(): if options.no_fs_fix: options.fs_fix = 'no' - if len(options.preserve): + if options.p: + if not options.preserve: + options.preserve = const_PRESERVE_p + else: + options.preserve += ',' + const_PRESERVE_p + + if options.preserve: preserve = set(options.preserve.split(',')) if not preserve.issubset(const_PRESERVE): error (_("Invalid --preserve value\nvalid values are:")) for value in const_PRESERVE: error('- %s' % value) exit(1) - else: - options.preserve = preserve - + options.preserve = preserve else: - options.preserve=set() + options.preserve = set() self.__sourcesSaving(options, args) diff --git a/gcp.1 b/gcp.1 index 2d2c04d..d8e5ab2 100644 --- a/gcp.1 +++ b/gcp.1 @@ -69,10 +69,13 @@ never follow symbolic links in sources .B \-f, \-\-force Overwrite existing files. .TP +.B \-p +Same as \-\-preserve=mode,ownership,timestamps +.TP .B \-\-preserve=PRESERVE Keep specified attributes. Attributes can be mode, ownership and timestamps. When several attributes are passed, they need to be separated by commas. Note -that timestamps preservation has some limits, see section LIMITS. +that timestamps preservation has some limits, see section LIMITATIONS. .TP .B \-\-no\-fs\-fix Don't fix file system naming incompatibilities. @@ -110,7 +113,7 @@ The exit status can be: \fB1\fP if at least one file has not been copied, or if something went wrong. .IP \[bu] \fB2\fP if all files have been copied but with some issues -.SH LIMITS +.SH LIMITATIONS Timestamps preservation with \-\-preserve option is limited by the os python module on POSIX systems. Currently, python only returns timestamps in float format, which is a smaller precision than what POSIX provides. Progress on this