From 4e77ef44844810e0749f86fd0b6c6c8e7ceb5178 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Sun, 19 Feb 2017 20:48:34 -0600 Subject: [PATCH] Address review comments --- beets/util/__init__.py | 22 ++++++++++------------ docs/reference/config.rst | 8 +++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index d7d45941c6..f6cd488d6d 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -478,16 +478,15 @@ def move(path, dest, replace=False): def link(path, dest, replace=False): """Create a symbolic link from path to `dest`. Raises an OSError if `dest` already exists, unless `replace` is True. Does nothing if - `path` == `dest`.""" - if (samefile(path, dest)): + `path` == `dest`. + """ + if samefile(path, dest): return - path = syspath(path) - dest = syspath(dest) - if os.path.exists(dest) and not replace: + if os.path.exists(syspath(dest)) and not replace: raise FilesystemError(u'file exists', 'rename', (path, dest)) try: - os.symlink(path, dest) + os.symlink(syspath(path), syspath(dest)) except NotImplementedError: # raised on python >= 3.2 and Windows versions before Vista raise FilesystemError(u'OS does not support symbolic links.' @@ -504,16 +503,15 @@ def link(path, dest, replace=False): def hardlink(path, dest, replace=False): """Create a hard link from path to `dest`. Raises an OSError if `dest` already exists, unless `replace` is True. Does nothing if - `path` == `dest`.""" - if (samefile(path, dest)): + `path` == `dest`. + """ + if samefile(path, dest): return - path = syspath(path) - dest = syspath(dest) - if os.path.exists(dest) and not replace: + if os.path.exists(syspath(dest)) and not replace: raise FilesystemError(u'file exists', 'rename', (path, dest)) try: - os.link(path, dest) + os.link(syspath(path), syspath(dest)) except NotImplementedError: raise FilesystemError(u'OS does not support hard links.' 'link', (path, dest), traceback.format_exc()) diff --git a/docs/reference/config.rst b/docs/reference/config.rst index bf3d89b2ef..40f8e9185f 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -451,11 +451,9 @@ Either ``yes`` or ``no``, indicating whether to use hard links instead of moving or copying or symlinking files. (It conflicts with the ``move``, ``copy``, and ``link`` options.) Defaults to ``no``. -This option only works on platforms that support hardlinks: i.e., Unixes. -It will fail on Windows. - -It's likely that you'll also want to set ``write`` to ``no`` if you use this -option to preserve the metadata on the linked files. +As with symbolic links (see :ref:`link`, above), this will not work on Windows +and you will want to set ``write`` to ``no``. Otherwise meatadata on the +original file will be modified. resume ~~~~~~