diff --git a/py/nodes/trigger_word_toggle.py b/py/nodes/trigger_word_toggle.py index 3888fcc1..bdd771dd 100644 --- a/py/nodes/trigger_word_toggle.py +++ b/py/nodes/trigger_word_toggle.py @@ -25,7 +25,6 @@ class TriggerWordToggle: FUNCTION = "process_trigger_words" def process_trigger_words(self, id, group_mode, **kwargs): - print("process_trigger_words kwargs: ", kwargs) trigger_words = kwargs.get("trigger_words", "") # Send trigger words to frontend PromptServer.instance.send_sync("trigger_word_update", { diff --git a/py/services/civitai_client.py b/py/services/civitai_client.py index 389fc491..a9929fc1 100644 --- a/py/services/civitai_client.py +++ b/py/services/civitai_client.py @@ -177,8 +177,6 @@ class CivitaiClient: headers = self._get_request_headers() url = f"{self.base_url}/models/{model_id}" - logger.info(f"Fetching model metadata from {url}") - async with session.get(url, headers=headers) as response: if response.status != 200: logger.warning(f"Failed to fetch model metadata: Status {response.status}") @@ -193,7 +191,6 @@ class CivitaiClient: } if metadata["description"] or metadata["tags"]: - logger.info(f"Successfully retrieved metadata for model {model_id}") return metadata else: logger.warning(f"No metadata found for model {model_id}") diff --git a/py/utils/file_utils.py b/py/utils/file_utils.py index 2ae05a60..1d1dc440 100644 --- a/py/utils/file_utils.py +++ b/py/utils/file_utils.py @@ -106,8 +106,11 @@ async def load_metadata(file_path: str) -> Optional[LoraMetadata]: needs_update = False - if data['file_path'] != normalize_path(data['file_path']): - data['file_path'] = normalize_path(data['file_path']) + # Compare paths without extensions + stored_path_base = os.path.splitext(data['file_path'])[0] + current_path_base = os.path.splitext(normalize_path(file_path))[0] + if stored_path_base != current_path_base: + data['file_path'] = normalize_path(file_path) needs_update = True preview_url = data.get('preview_url', '') @@ -118,11 +121,15 @@ async def load_metadata(file_path: str) -> Optional[LoraMetadata]: if new_preview_url != preview_url: data['preview_url'] = new_preview_url needs_update = True - elif preview_url != normalize_path(preview_url): - data['preview_url'] = normalize_path(preview_url) - needs_update = True + else: + # Compare preview paths without extensions + stored_preview_base = os.path.splitext(preview_url)[0] + current_preview_base = os.path.splitext(normalize_path(preview_url))[0] + if stored_preview_base != current_preview_base: + data['preview_url'] = normalize_path(preview_url) + needs_update = True - # Ensure all fields are present, due to updates adding new fields + # Ensure all fields are present if 'tags' not in data: data['tags'] = [] needs_update = True diff --git a/static/js/managers/UpdateService.js b/static/js/managers/UpdateService.js index 600cf562..050fdff5 100644 --- a/static/js/managers/UpdateService.js +++ b/static/js/managers/UpdateService.js @@ -28,7 +28,10 @@ export class UpdateService { } // Perform update check if needed - this.checkForUpdates(); + this.checkForUpdates().then(() => { + // Ensure badges are updated after checking + this.updateBadgeVisibility(); + }); // Set up event listener for update button const updateToggle = document.getElementById('updateToggleBtn'); @@ -43,7 +46,9 @@ export class UpdateService { async checkForUpdates() { // Check if we should perform an update check const now = Date.now(); - if (now - this.lastCheckTime < this.updateCheckInterval) { + const forceCheck = this.lastCheckTime === 0; + + if (!forceCheck && now - this.lastCheckTime < this.updateCheckInterval) { // If we already have update info, just update the UI if (this.updateAvailable) { this.updateBadgeVisibility(); @@ -61,8 +66,8 @@ export class UpdateService { this.latestVersion = data.latest_version || "v0.0.0"; this.updateInfo = data; - // Determine if update is available - this.updateAvailable = data.update_available; + // Explicitly set update availability based on version comparison + this.updateAvailable = this.isNewerVersion(this.latestVersion, this.currentVersion); // Update last check time this.lastCheckTime = now; @@ -83,6 +88,37 @@ export class UpdateService { } } + // Helper method to compare version strings + isNewerVersion(latestVersion, currentVersion) { + if (!latestVersion || !currentVersion) return false; + + // Remove 'v' prefix if present + const latest = latestVersion.replace(/^v/, ''); + const current = currentVersion.replace(/^v/, ''); + + // Split version strings into components + const latestParts = latest.split(/[-\.]/); + const currentParts = current.split(/[-\.]/); + + // Compare major, minor, patch versions + for (let i = 0; i < 3; i++) { + const latestNum = parseInt(latestParts[i] || '0', 10); + const currentNum = parseInt(currentParts[i] || '0', 10); + + if (latestNum > currentNum) return true; + if (latestNum < currentNum) return false; + } + + // If numeric versions are the same, check for beta/alpha status + const latestIsBeta = latest.includes('beta') || latest.includes('alpha'); + const currentIsBeta = current.includes('beta') || current.includes('alpha'); + + // Release version is newer than beta/alpha + if (!latestIsBeta && currentIsBeta) return true; + + return false; + } + updateBadgeVisibility() { const updateToggle = document.querySelector('.update-toggle'); const updateBadge = document.querySelector('.update-toggle .update-badge'); @@ -94,14 +130,17 @@ export class UpdateService { : "Check Updates"; } + // Force updating badges visibility based on current state + const shouldShow = this.updateNotificationsEnabled && this.updateAvailable; + if (updateBadge) { - const shouldShow = this.updateNotificationsEnabled && this.updateAvailable; updateBadge.classList.toggle('hidden', !shouldShow); + console.log("Update badge visibility:", !shouldShow ? "hidden" : "visible"); } if (cornerBadge) { - const shouldShow = this.updateNotificationsEnabled && this.updateAvailable; cornerBadge.classList.toggle('hidden', !shouldShow); + console.log("Corner badge visibility:", !shouldShow ? "hidden" : "visible"); } } @@ -194,6 +233,8 @@ export class UpdateService { async manualCheckForUpdates() { this.lastCheckTime = 0; // Reset last check time to force check await this.checkForUpdates(); + // Ensure badge visibility is updated after manual check + this.updateBadgeVisibility(); } }