Skip to content

Commit

Permalink
fixed nasty profile sync bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezyma committed Dec 24, 2021
1 parent 7c8701b commit 35299b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/profilesync/plugins/profilesync_tool_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def profileRename(self, profile, oldName, newName):
self.profilesync.renameProfile(oldName, newName)

def syncProfile(self, modName, oldPriority, newPriority):
self.profilesync.syncToGroup(self.organiser.profileName())
#self.profilesync.syncToGroup(self.organiser.profileName())
qInfo("Moved " + modName + " from " + str(oldPriority) + " to " + str(newPriority))
self.profilesync.syncFromCurrent()

def checkGroupName(self):
if self.addText.text().strip() == "" or self.addText.text().lower().strip() in [x.lower().strip() for x in self.profilesync.getSyncGroups().keys()]:
Expand Down
36 changes: 24 additions & 12 deletions src/profilesync/profilesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,32 @@ def getProfileGroup(self, profileName=str):
return g
return ""

def syncFromCurrent(self):
profile = self.organiser.profile()
group = self.getProfileGroup(profile.name())
if group != "":
qInfo("Sync from Profile " + profile.name() + " to Group " + group)
mods = self.organiser.modList().allModsByProfilePriority(profile)
modNl = []
for m in mods:
modNl.append(m + "\n")
self.setGroupModlist(group, modNl)

def groupToProfile(self, groupName=str, profileName=str):
qInfo("Sync from Group " + groupName + " to Profile " + profileName)
groupList = self.getGroupModlist(groupName)
mods, enabled = self.profileModlist(profileName)
results = []
for mod in groupList:
if mod in enabled:
results.append("+" + mod)
else:
results.append("-" + mod)
results.reverse()
path = self.paths.profileModlistPath(profileName)
with open(str(path), "w") as w:
w.writelines(results)
if groupName != "":
groupList = self.getGroupModlist(groupName)
mods, enabled = self.profileModlist(profileName)
results = []
for mod in groupList:
if mod in enabled:
results.append("+" + mod)
else:
results.append("-" + mod)
results.reverse()
path = self.paths.profileModlistPath(profileName)
with open(str(path), "w") as w:
w.writelines(results)

def removeProfileFromGroup(self, groupName=str, profileName=str):
groups = self.getSyncGroups()
Expand Down

0 comments on commit 35299b0

Please sign in to comment.