Remove ProjectConfig cache when "platformio.ini" was modified outside

This commit is contained in:
Ivan Kravets
2019-08-25 18:37:14 +03:00
parent 785be3cb26
commit cba2f4d7b6
4 changed files with 15 additions and 10 deletions

View File

@ -6,6 +6,11 @@ Release Notes
PlatformIO 4.0
--------------
4.0.3 (2019-??-??)
~~~~~~~~~~~~~~~~~~
* Remove ProjectConfig cache when "platformio.ini" was modified outside
4.0.2 (2019-08-23)
~~~~~~~~~~~~~~~~~~

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION = (4, 0, 2)
VERSION = (4, 0, "3a1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -388,7 +388,6 @@ def fill_project_envs(ctx, project_dir, board_ids, project_option, env_prefix,
if modified:
config.save()
config.reset_instances()
def _install_dependent_platforms(ctx, platforms):

View File

@ -16,7 +16,7 @@ import glob
import json
import os
import re
from os.path import expanduser, isfile
from os.path import expanduser, getmtime, isfile
import click
@ -72,13 +72,14 @@ class ProjectConfig(object):
@staticmethod
def get_instance(path):
if path not in ProjectConfig._instances:
ProjectConfig._instances[path] = ProjectConfig(path)
return ProjectConfig._instances[path]
@staticmethod
def reset_instances():
ProjectConfig._instances = {}
mtime = getmtime(path) if isfile(path) else 0
instance = ProjectConfig._instances.get(path)
if instance and instance["mtime"] != mtime:
instance = None
if not instance:
instance = {"mtime": mtime, "config": ProjectConfig(path)}
ProjectConfig._instances[path] = instance
return instance["config"]
def __init__(self, path, parse_extra=True, expand_interpolations=True):
self.path = path