Update engine.py

This commit is contained in:
2026-01-17 12:50:31 +01:00
parent 8025d114de
commit 0f009643f2

View File

@@ -61,15 +61,16 @@ class SorterEngine:
return t_dst, c_dst return t_dst, c_dst
@staticmethod @staticmethod
def save_favorite(name, path_t, path_c): def revert_action(action):
favs = SorterEngine.load_favorites() if action['type'] in ['link_standard', 'link_solo']:
favs[name] = {"target": path_t, "control": path_c} if os.path.exists(action['t_dst']): shutil.move(action['t_dst'], action['t_src'])
with open(SorterEngine.CONFIG_PATH, 'w') as f: if os.path.exists(action['c_dst']): os.remove(action['c_dst'])
json.dump(favs, f) elif action['type'] == 'unused':
if os.path.exists(action['t_dst']): shutil.move(action['t_dst'], action['t_src'])
if os.path.exists(action['c_dst']): shutil.move(action['c_dst'], action['c_src'])
@staticmethod @staticmethod
def load_favorites(): def load_favorites():
if os.path.exists(SorterEngine.CONFIG_PATH): if os.path.exists(SorterEngine.CONFIG_PATH):
with open(SorterEngine.CONFIG_PATH, 'r') as f: with open(SorterEngine.CONFIG_PATH, 'r') as f: return json.load(f)
return json.load(f)
return {} return {}