Open brugger1 opened 3 years ago
Should it work? There is a dirname option in ExportDBAttributes for specifying location of the file.
I see that now. The default value is "." and by adding debug information I see that "./" is appended to the absolute path specified in "filename". This wasn't obvious to Steve Langer and it wasn't obvious to me. It may make sense in the GUI, but it is strange to have for a scripting interface.
Changing the attributes probably isn't a good idea. We could probably improve things so that people don't get confused by it and waste lots of time figuring out the problem.
A couple of thoughts.
1) If the filename starts with a "/" print an error. 2) If the filename starts with a "/", don't prepend the dir path.
Thoughts?
The relevant code is in the file ./engine/main/NetworkManager.C
in ExportSingleDatabas
around line 5008.
Just for clarity, here are the lines @brugger pointed out.
There would have to be logic for Windows as well, where full paths don't begin with "/".
Using FileFunctions::dirname on filename might be helpful. If it returns an empty string, then prepend the atts dirname to filename to form qualFilename.
In my work for #5462, I have modified export_db.py test to also test changing dirnames. We should add a tests for filenames that are fully qualified paths.
Let's go with option 1, displaying an error message. We should try to catch the error early on so that we don't do a lot of work before catching it in NetworkManager. We may need to put a common validity check in the GUI and CLI or find somewhere early on that both share.
The following script works.
When "export_file" is changed to an absolute path it fails with the error: