diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-05-17 06:26:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 06:26:26 +0000 |
commit | 85232a5b26666854deae59cf950f744740dd5c37 (patch) | |
tree | 3af76d8c6ba3173ffd925336d902da058df4e02d /modules/extensions.py | |
parent | 56a2672831751480f94a018f861f0143a8234ae8 (diff) | |
parent | 4b07f2f584596604c4499efb0b0295e96985080f (diff) | |
download | stable-diffusion-webui-gfx803-85232a5b26666854deae59cf950f744740dd5c37.tar.gz stable-diffusion-webui-gfx803-85232a5b26666854deae59cf950f744740dd5c37.tar.bz2 stable-diffusion-webui-gfx803-85232a5b26666854deae59cf950f744740dd5c37.zip |
Merge branch 'dev' into taesd-a
Diffstat (limited to 'modules/extensions.py')
-rw-r--r-- | modules/extensions.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/modules/extensions.py b/modules/extensions.py index 34d9d654..359a7aa5 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,18 @@ 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))
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 = repo.head.commit.hexsha
+ self.version = repo.git.describe("--always", "--tags") # compared to `self.commit_hash[:8]` this takes about 30% more time total but since we run it in parallel we don't care
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
|