mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
fix the large file parsing in project sync
This commit is contained in:
committed by
Ryan Petrello
parent
646c9cc708
commit
60d6832971
@@ -6,7 +6,6 @@ import codecs
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from itertools import islice
|
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
@@ -82,14 +81,20 @@ def could_be_inventory(project_path, dir_path, filename):
|
|||||||
|
|
||||||
# Filter files that do not use a character set consistent with
|
# Filter files that do not use a character set consistent with
|
||||||
# Ansible inventory mainly
|
# Ansible inventory mainly
|
||||||
|
matched = False
|
||||||
try:
|
try:
|
||||||
# only read through first 10 lines for performance
|
# only read through first 10 lines for performance
|
||||||
with codecs.open(inventory_path, 'r', encoding='utf-8', errors='ignore') as inv_file:
|
with open(inventory_path, encoding='utf-8', errors='ignore') as inv_file:
|
||||||
for line in islice(inv_file, 10):
|
for i, line in enumerate(inv_file):
|
||||||
if not valid_inventory_re.match(line):
|
if i > 10:
|
||||||
return None
|
break
|
||||||
|
elif valid_inventory_re.match(line):
|
||||||
|
matched = True
|
||||||
|
break
|
||||||
except IOError:
|
except IOError:
|
||||||
return None
|
return None
|
||||||
|
if not matched:
|
||||||
|
return None
|
||||||
return inventory_rel_path
|
return inventory_rel_path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user