aboutsummaryrefslogtreecommitdiff
path: root/modules/extensions.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-05-18 10:26:35 +0300
committerGitHub <noreply@github.com>2023-05-18 10:26:35 +0300
commit97e1cf69c04a3c62aa1bb19a14ffc948d9cc6c4e (patch)
tree7a24bdd31580fe0e4bf8d4205b57b55df0a2568d /modules/extensions.py
parent484948f5c0b755a921c02cccbcacb2684a86a814 (diff)
parentbb431df52bf3dc5e233e42907f2d8f56e4fb6c0c (diff)
Merge branch 'dev' into master
Diffstat (limited to 'modules/extensions.py')
-rw-r--r--modules/extensions.py22
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