Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
This should have been part of commti 4a4bb62
Issue #56
  • Loading branch information
perrette committed May 10, 2023
1 parent 4a4bb62 commit 88d6f6c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions papers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def checksum(fname):


# move / copy
def move(f1, f2, copy=False, interactive=True, dryrun=False, hardlink=True):
def move(f1, f2, copy=False, interactive=True, dryrun=False, hardlink=False):
maybe = 'dry-run:: ' if dryrun else ''
dirname = os.path.dirname(f2)
if dirname and not os.path.exists(dirname):
Expand Down Expand Up @@ -112,16 +112,25 @@ def move(f1, f2, copy=False, interactive=True, dryrun=False, hardlink=True):

if copy:
# If we can do a hard-link instead of copy-ing, let's do:
if hardlink:
def _hardlink(f1, f2):
cmd = f'{maybe}ln {f1} {f2}'
logger.info(cmd)
if not dryrun:
os.link(f1, f2)

else:
def _copy(f1, f2):
logger.info(f'{maybe}cp {f1} {f2}')
if not dryrun:
shutil.copy(f1, f2)

if hardlink:
try:
_hardlink(f1, f2)
except:
_copy(f1, f2)
else:
_copy(f1, f2)

else:
cmd = f'{maybe}mv {f1} {f2}'
logger.info(cmd)
Expand Down

0 comments on commit 88d6f6c

Please sign in to comment.