Skip to content

Commit 168374e

Browse files
committed
Updating binding logic to find minimal path and update symlinks when source changes.
1 parent 2279f2c commit 168374e

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

‎src/run.py‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,22 @@ def sym_safe(input_data, target, rename_func=rename):
163163
filename = os.path.basename(file)
164164
renamed = os.path.join(target, rename_func(filename))
165165
input_fastqs.append(renamed)
166-
166+
# Get the real path to the file,
167+
# this follows any symlinks to
168+
# their source
169+
real_path = os.path.abspath(os.path.realpath(file))
170+
if exists(renamed):
171+
# Check to see if the realpath has changed
172+
# if so, update the symlink pointer to the
173+
# real file.
174+
if os.path.abspath(os.path.realpath(renamed)) != real_path:
175+
# Need to update the symlink
176+
# the pointer to the orginial
177+
# file has changed.
178+
try: os.unlink(renamed)
179+
except PermissionError:
180+
err("Warning: Failed to create a new symlink for the following updated input file:")
181+
err(" └── '{0}' -> '{1}'".format(renamed, real_path))
167182
if not exists(renamed):
168183
# Create a symlink if it does not already exist
169184
# Follow source symlinks to resolve any binding issues
@@ -361,10 +376,10 @@ def bind(sub_args, config):
361376
# genome paths
362377
rawdata_bind_paths = [os.path.realpath(p) for p in config['project']['datapath'].split(',')]
363378
working_directory = os.path.realpath(config['project']['workpath'])
364-
genome_bind_paths = resolve_additional_bind_paths(bindpaths)
365-
bindpaths = [working_directory] + rawdata_bind_paths + genome_bind_paths
379+
bindpaths = resolve_additional_bind_paths(
380+
[working_directory] + rawdata_bind_paths + bindpaths
381+
)
366382
bindpaths = list(set([p for p in bindpaths if p != os.sep]))
367-
368383
return bindpaths
369384

370385

@@ -421,7 +436,7 @@ def add_user_information(config):
421436

422437
# Update config with home directory and
423438
# username
424-
config['project']['userhome'] = home
439+
# config['project']['userhome'] = home
425440
config['project']['username'] = username
426441

427442
return config

0 commit comments

Comments
 (0)