diff --git a/softpack_core/artifacts.py b/softpack_core/artifacts.py index 96fae0d..6f9681e 100644 --- a/softpack_core/artifacts.py +++ b/softpack_core/artifacts.py @@ -81,6 +81,7 @@ class Artifacts: users_folder_name = "users" groups_folder_name = "groups" credentials_callback = None + updated = True @dataclass class Object: @@ -408,6 +409,7 @@ def commit_and_push( ) remote = self.repo.remotes[0] remote.push([self.repo.head.name], callbacks=self.credentials_callback) + self.updated = True return oid def build_tree( diff --git a/softpack_core/schemas/environment.py b/softpack_core/schemas/environment.py index 82d9a1a..f036d84 100644 --- a/softpack_core/schemas/environment.py +++ b/softpack_core/schemas/environment.py @@ -323,7 +323,6 @@ class Environment: tags: list[str] hidden: bool cachedEnvs: list["Environment"] = field(default_factory=list) - envsUpdates: bool = True requested: Optional[datetime.datetime] = None build_start: Optional[datetime.datetime] = None @@ -337,7 +336,7 @@ def iter(cls) -> list["Environment"]: Returns: Iterable[Environment]: An iterator of Environment objects. """ - if not cls.envsUpdates: + if not artifacts.updated: return cls.cachedEnvs statuses = BuildStatus.get_all() @@ -372,7 +371,7 @@ def iter(cls) -> list["Environment"]: env.build_done = status.build_done cls.cachedEnvs = environment_objects - cls.envsUpdates = False + artifacts.updated = False return environment_objects @@ -549,7 +548,6 @@ def create_new_env( ], True, ) - cls.envsUpdates = True artifacts.commit_and_push(tree_oid, "create environment folder") except RuntimeError as e: return InvalidInputError( @@ -649,7 +647,6 @@ def store_metadata(cls, environment_path: Path, metadata: Box) -> None: metadata.to_yaml(), overwrite=True, ) - cls.envsUpdates = True artifacts.commit_and_push(tree_oid, "update metadata") @classmethod @@ -686,7 +683,6 @@ def delete(cls, name: str, path: str) -> DeleteResponse: # type: ignore """ if artifacts.get(Path(path), name): tree_oid = artifacts.delete_environment(name, path) - cls.envsUpdates = True artifacts.commit_and_push(tree_oid, "delete environment") return DeleteEnvironmentSuccess( message="Successfully deleted the environment" @@ -856,7 +852,6 @@ async def write_artifacts( tree_oid = artifacts.create_files( Path(folder_path), new_files, overwrite=True ) - cls.envsUpdates = True artifacts.commit_and_push(tree_oid, "write artifact") return WriteArtifactSuccess( message="Successfully written artifact(s)",