diff options
author | Jordan Borean <jborean93@gmail.com> | 2023-04-15 06:07:45 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 13:07:45 -0700 |
commit | e267230a6b4abcab47920ea7780f343d0c674882 (patch) | |
tree | f9b3d9ddd8d4515eeeffac995e0e378815b7c490 /lib | |
parent | 25e77b7c98aebaacfd6ff97e2ff82c8271ca61b5 (diff) | |
download | ansible-e267230a6b4abcab47920ea7780f343d0c674882.tar.gz |
Improve Ansible.Basic.cs tempdir uniqueness (#80328) (#80330)
* Improve Ansible.Basic.cs tempdir uniqueness
The current tempdir naming scheme can result in the same name if the
remote worker starts at the same time as another. By using the process
id it should add enough uniqueness to avoid this situation.
* Fix sanity issues
* Fix up compile issue on older hosts
(cherry picked from commit fb6b90fe4255e9995706905e2a9cde205648c0d2)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/module_utils/csharp/Ansible.Basic.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/csharp/Ansible.Basic.cs b/lib/ansible/module_utils/csharp/Ansible.Basic.cs index c68281ef1b..16480992e8 100644 --- a/lib/ansible/module_utils/csharp/Ansible.Basic.cs +++ b/lib/ansible/module_utils/csharp/Ansible.Basic.cs @@ -176,7 +176,8 @@ namespace Ansible.Basic } string dateTime = DateTime.Now.ToFileTime().ToString(); - string dirName = String.Format("ansible-moduletmp-{0}-{1}", dateTime, new Random().Next(0, int.MaxValue)); + string dirName = String.Format("ansible-moduletmp-{0}-{1}-{2}", dateTime, System.Diagnostics.Process.GetCurrentProcess().Id, + new Random().Next(0, int.MaxValue)); string newTmpdir = Path.Combine(baseDir, dirName); #if CORECLR DirectoryInfo tmpdirInfo = Directory.CreateDirectory(newTmpdir); |