-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check the stat dictionary's size, not the variable's size #323
Conversation
@@ -23,4 +23,4 @@ | |||
TOX_CONSTRAINTS_FILE: "{{ constraints_file.path }}" | |||
# Backward compatibility, to be removed | |||
UPPER_CONSTRAINTS_FILE: "{{ constraints_file.path }}" | |||
when: constraints_stat.size > 0 | |||
when: constraints_file is defined and constraints_stat.size > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above condition looks good but more appropriate can be to use constraints_stat.exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing this, I missed that part from the docs.
@@ -23,4 +23,4 @@ | |||
TOX_CONSTRAINTS_FILE: "{{ constraints_file.path }}" | |||
# Backward compatibility, to be removed | |||
UPPER_CONSTRAINTS_FILE: "{{ constraints_file.path }}" | |||
when: constraints_stat.size > 0 | |||
when: constraints_file is defined and constraints_stat.size > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be constraints_stat.stat.size
, it's still missing the .stat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a new revision of the change to address this.
The ansible.builtin.stat module returns a dictionary where the key to use is 'stat' in order to get the file stats. Add the missing stat key. Failure to do this causes the task to fail with size not being a key in the dictionary. ref: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html#ansible-collections-ansible-builtin-stat-module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The ansible.builtin.stat module returns a dictionary where the key to use is 'stat' in order to get the file stats. Add the missing stat key. Failure to do this causes the task to fail with size not being a key in the dictionary.
ref: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html#ansible-collections-ansible-builtin-stat-module