From 46216ed90a1e87366e040ad3eaf32a10c023fe21 Mon Sep 17 00:00:00 2001 From: jad2121 Date: Wed, 13 Mar 2024 19:49:57 -0400 Subject: [PATCH] added persistant custom patterns. Anything you add to the .config/fabric/patterns folder will persist --- helper_files/save.py | 1 - installer/client/cli/utils.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/helper_files/save.py b/helper_files/save.py index 9c67744..eaeef21 100755 --- a/helper_files/save.py +++ b/helper_files/save.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 import argparse import os import sys diff --git a/installer/client/cli/utils.py b/installer/client/cli/utils.py index 880c96d..840d5d1 100644 --- a/installer/client/cli/utils.py +++ b/installer/client/cli/utils.py @@ -268,7 +268,6 @@ class Standalone: else: print(f"Error: {e}") print(e) - def fetch_available_models(self): gptlist = [] @@ -351,6 +350,17 @@ class Update: if os.path.exists(patterns_source_path): # If the patterns directory already exists, remove it before copying over the new one if os.path.exists(self.pattern_directory): + old_pattern_contents = os.listdir(self.pattern_directory) + new_pattern_contents = os.listdir(patterns_source_path) + custom_patterns = [] + for pattern in old_pattern_contents: + if pattern not in new_pattern_contents: + custom_patterns.append(pattern) + if custom_patterns: + for pattern in custom_patterns: + custom_path = os.path.join( + self.pattern_directory, pattern) + shutil.move(custom_path, patterns_source_path) shutil.rmtree(self.pattern_directory) shutil.copytree(patterns_source_path, self.pattern_directory) print("Patterns updated successfully.")