diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-21 14:37:09 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-21 14:37:09 +0000 |
commit | 1f3182924ba8e70d0e0fc3ed270782f324376ba3 (patch) | |
tree | 27a9e5167e5b981dfe56f5084ea8e1e8743f3fc0 /modules/extensions.py | |
parent | 89f9faa63388756314e8a1d96cf86bf5e0663045 (diff) | |
parent | fdaf0147b6d2a5f599464bb7c65817ef5832eff1 (diff) | |
download | stable-diffusion-webui-gfx803-1f3182924ba8e70d0e0fc3ed270782f324376ba3.tar.gz stable-diffusion-webui-gfx803-1f3182924ba8e70d0e0fc3ed270782f324376ba3.tar.bz2 stable-diffusion-webui-gfx803-1f3182924ba8e70d0e0fc3ed270782f324376ba3.zip |
Merge branch 'dev' into release_candidate
Diffstat (limited to 'modules/extensions.py')
-rw-r--r-- | modules/extensions.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/modules/extensions.py b/modules/extensions.py index 34d9d654..624832a0 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -1,13 +1,12 @@ import os
import sys
+import threading
import traceback
-import time
-from datetime import datetime
import git
from modules import shared
-from modules.paths_internal import extensions_dir, extensions_builtin_dir, script_path
+from modules.paths_internal import extensions_dir, extensions_builtin_dir, script_path # noqa: F401
extensions = []
@@ -25,6 +24,8 @@ def active(): class Extension:
+ lock = threading.Lock()
+
def __init__(self, name, path, enabled=True, is_builtin=False):
self.name = name
self.path = path
@@ -43,8 +44,13 @@ class Extension: if self.is_builtin or self.have_info_from_repo:
return
- self.have_info_from_repo = True
+ with self.lock:
+ if self.have_info_from_repo:
+ return
+ self.do_read_info_from_repo()
+
+ def do_read_info_from_repo(self):
repo = None
try:
if os.path.exists(os.path.join(self.path, ".git")):
@@ -59,18 +65,19 @@ class Extension: try:
self.status = 'unknown'
self.remote = next(repo.remote().urls, None)
- head = repo.head.commit
- self.commit_date = repo.head.commit.committed_date
- ts = time.asctime(time.gmtime(self.commit_date))
+ commit = repo.head.commit
+ self.commit_date = commit.committed_date
if repo.active_branch:
self.branch = repo.active_branch.name
- self.commit_hash = head.hexsha
- self.version = f'{self.commit_hash[:8]} ({ts})'
+ self.commit_hash = commit.hexsha
+ self.version = self.commit_hash[:8]
except Exception as ex:
print(f"Failed reading extension data from Git repository ({self.name}): {ex}", file=sys.stderr)
self.remote = None
+ self.have_info_from_repo = True
+
def list_files(self, subdir, extension):
from modules import scripts
|