mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 19:20:22 -07:00
File module - fix unicode paths and add a test (#57558)
* File module - Fix unicode paths * Add a test for unicode paths for the file module
This commit is contained in:
parent
93a85b6c86
commit
cd77ea3c7f
3 changed files with 18 additions and 1 deletions
|
@ -372,7 +372,8 @@ def initial_diff(path, state, prev_state):
|
||||||
'directories': [],
|
'directories': [],
|
||||||
'files': [],
|
'files': [],
|
||||||
}
|
}
|
||||||
for base_path, sub_folders, files in os.walk(path):
|
b_path = to_bytes(path, errors='surrogate_or_strict')
|
||||||
|
for base_path, sub_folders, files in os.walk(b_path):
|
||||||
for folder in sub_folders:
|
for folder in sub_folders:
|
||||||
folderpath = os.path.join(base_path, folder)
|
folderpath = os.path.join(base_path, folder)
|
||||||
walklist['directories'].append(folderpath)
|
walklist['directories'].append(folderpath)
|
||||||
|
|
|
@ -32,6 +32,12 @@
|
||||||
- name: Run tests for directory as dest
|
- name: Run tests for directory as dest
|
||||||
include: directory_as_dest.yml
|
include: directory_as_dest.yml
|
||||||
|
|
||||||
|
- name: Run tests for unicode
|
||||||
|
include: unicode_path.yml
|
||||||
|
environment:
|
||||||
|
LC_ALL: C
|
||||||
|
LANG: C
|
||||||
|
|
||||||
- name: decide to include or not include selinux tests
|
- name: decide to include or not include selinux tests
|
||||||
include: selinux_tests.yml
|
include: selinux_tests.yml
|
||||||
when: selinux_installed is defined and selinux_installed.stdout != "" and selinux_enabled.stdout != "Disabled"
|
when: selinux_installed is defined and selinux_installed.stdout != "" and selinux_enabled.stdout != "Disabled"
|
||||||
|
|
10
test/integration/targets/file/tasks/unicode_path.yml
Normal file
10
test/integration/targets/file/tasks/unicode_path.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
- name: create local file with unicode filename and content
|
||||||
|
lineinfile:
|
||||||
|
dest: "{{ output_dir }}/语/汉语.txt"
|
||||||
|
create: true
|
||||||
|
line: 汉语
|
||||||
|
|
||||||
|
- name: remove local file with unicode filename and content
|
||||||
|
file:
|
||||||
|
path: "{{ output_dir }}/语/汉语.txt"
|
||||||
|
state: absent
|
Loading…
Add table
Add a link
Reference in a new issue