mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #9627 from jainnikhil30/fix_large_file_project_sync
fix the large file parsing in project sync SUMMARY Fixes the issue of scm update stuck on reading large files because of islice trying to read the whole file. ISSUE TYPE Bugfix Pull Request COMPONENT NAME API Reviewed-by: Ryan Petrello <None> Reviewed-by: None <None>
This commit is contained in:
commit
634d432de4
@ -6,7 +6,6 @@ import codecs
|
||||
import re
|
||||
import os
|
||||
import logging
|
||||
from itertools import islice
|
||||
from configparser import ConfigParser
|
||||
|
||||
# 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
|
||||
# Ansible inventory mainly
|
||||
matched = False
|
||||
try:
|
||||
# only read through first 10 lines for performance
|
||||
with codecs.open(inventory_path, 'r', encoding='utf-8', errors='ignore') as inv_file:
|
||||
for line in islice(inv_file, 10):
|
||||
if not valid_inventory_re.match(line):
|
||||
return None
|
||||
with open(inventory_path, encoding='utf-8', errors='ignore') as inv_file:
|
||||
for i, line in enumerate(inv_file):
|
||||
if i > 10:
|
||||
break
|
||||
elif valid_inventory_re.match(line):
|
||||
matched = True
|
||||
break
|
||||
except IOError:
|
||||
return None
|
||||
if not matched:
|
||||
return None
|
||||
return inventory_rel_path
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user