|
28 | 28 |
|
29 | 29 | main_redirector = "root://redirector.osgstorage.org" |
30 | 30 | stash_origin = "root://stash.osgconnect.net" |
31 | | -writeback_host = "http://stash-xrd.osgconnect.net:1094" |
| 31 | +writeback_host = "https://redirector.osgstorage.org:8443" |
32 | 32 |
|
33 | 33 | # Global variable for nearest cache |
34 | 34 | nearest_cache = None |
@@ -58,9 +58,6 @@ def doWriteBack(source, destination): |
58 | 58 | if scitoken_contents is None: |
59 | 59 | logging.error("Unable to find scitokens.use file") |
60 | 60 | return 1 |
61 | | - |
62 | | - # Remove the stash:// at the beginning, don't need it |
63 | | - destination = destination.replace("stash://", "") |
64 | 61 |
|
65 | 62 | # Check if the source file is zero-length |
66 | 63 | statinfo = os.stat(source) |
@@ -153,13 +150,32 @@ def doStashCpSingle(sourceFile, destination, methods, debug=False): |
153 | 150 |
|
154 | 151 | global nearest_cache |
155 | 152 |
|
156 | | - # Check if the desitnation is a protocol like stash:///user/blah |
157 | | - if destination.startswith("stash://"): |
158 | | - # Source file exists, must be a writeback |
159 | | - return doWriteBack(sourceFile, destination) |
160 | | - |
| 153 | + # Parse the source and destination with urlparse |
| 154 | + source_url = urlparse(sourceFile) |
| 155 | + dest_url = urlparse(destination) |
| 156 | + understoodSchemes = ["stash", "file", ""] |
| 157 | + if source_url.scheme not in understoodSchemes: |
| 158 | + logging.error("Do not understand scheme: %s", source_url.scheme) |
| 159 | + return 1 |
| 160 | + |
| 161 | + if dest_url.scheme not in understoodSchemes: |
| 162 | + logging.error("Do not understand scheme: %s", dest_url.scheme) |
| 163 | + return 1 |
| 164 | + |
| 165 | + if dest_url.scheme == "stash": |
| 166 | + return doWriteBack(source_url.path, dest_url.path) |
| 167 | + |
| 168 | + if dest_url.scheme == "file": |
| 169 | + destination = dest_url.path |
| 170 | + |
| 171 | + if source_url.scheme == "stash": |
| 172 | + sourceFile = source_url.path |
| 173 | + |
| 174 | + if not sourceFile.startswith("/"): |
| 175 | + sourceFile = "/" + sourceFile |
| 176 | + |
161 | 177 | sitename = os.environ.setdefault("OSG_SITE_NAME", "siteNotFound") |
162 | | - |
| 178 | + |
163 | 179 | # Fill out the payload as much as possible |
164 | 180 | filename = destination + '/' + sourceFile.split('/')[-1] |
165 | 181 |
|
@@ -663,9 +679,6 @@ def main(): |
663 | 679 | source=opts[0] |
664 | 680 | destination=opts[1] |
665 | 681 |
|
666 | | - if not source.startswith("/"): |
667 | | - source = "/" + source |
668 | | - |
669 | 682 | # Check for manually entered cache to use |
670 | 683 | if 'NEAREST_CACHE' in os.environ: |
671 | 684 | nearest_cache = os.environ['NEAREST_CACHE'] |
|
0 commit comments