Skip to content

Commit

Permalink
ingest: detect when we are re-linking the same file
Browse files Browse the repository at this point in the history
This should make re-ingesting data less painful.
  • Loading branch information
PaulPrice committed Feb 5, 2020
1 parent 97f1149 commit 2029b99
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/lsst/pipe/tasks/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ def ingest(self, infile, outfile, mode="move", dryrun=False):
assertCanCopy(infile, outfile)
shutil.copyfile(infile, outfile)
elif mode == "link":
if os.path.exists(outfile):
if os.path.samefile(infile, outfile):
self.log.debug("Already linked %s to %s: ignoring" % (infile, outfile))
else:
self.log.warn("%s already has a file at the target location (%s): ignoring "
"(set clobber=True to overwrite)" % (infile, outfile))
return False
os.symlink(os.path.abspath(infile), outfile)
elif mode == "move":
assertCanCopy(infile, outfile)
Expand Down

0 comments on commit 2029b99

Please sign in to comment.