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 PlatformIO 4.0
-------------- --------------
4.0.3 (2019-??-??)
~~~~~~~~~~~~~~~~~~
* Remove ProjectConfig cache when "platformio.ini" was modified outside
4.0.2 (2019-08-23) 4.0.2 (2019-08-23)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

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

View File

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

View File

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