Skip to content

Commit 10debfa

Browse files
Merge pull request #84 in CATS/pyclowder2 from Improvement/CATS-975-add_links_to_local_files to develop
* commit 'cc47ffa2700b15d796baaaaa2adef3e666d77465': Added making a temp folder for cases where multiple instance are running on the same machine Added linking to local files when the local file name doesn't match expected file name
2 parents 66fc770 + cc47ffa commit 10debfa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pyclowder/connectors.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,24 @@ def _prepare_dataset(self, host, secret_key, resource):
296296
tmp_files_created = []
297297
tmp_dirs_created = []
298298

299+
# Create a temporary folder to hold any links to local files we may need
300+
temp_link_dir = tempfile.mkdtemp()
301+
tmp_dirs_created.append(temp_link_dir)
302+
299303
# first check if any files in dataset accessible locally
300304
ds_file_list = pyclowder.datasets.get_file_list(self, host, secret_key, resource["id"])
301305
for ds_file in ds_file_list:
302306
file_path = self._check_for_local_file(host, secret_key, ds_file)
303307
if not file_path:
304308
missing_files.append(ds_file)
305309
else:
310+
# Create a link to the original file if the "true" name of the file doesn't match what's on disk
311+
if not file_path.lower().endswith(ds_file['filename'].lower()):
312+
ln_name = io.path.join(temp_link_dir, ds_file['filename'])
313+
os.symlink(file_path, ln_name)
314+
tmp_files_created.append(ln_name)
315+
file_path = ln_name
316+
306317
# Also get file metadata in format expected by extrator
307318
(file_md_dir, file_md_tmp) = self._download_file_metadata(host, secret_key, ds_file['id'],
308319
ds_file['filepath'])

0 commit comments

Comments
 (0)