Skip to content

Commit

Permalink
Added option to force update
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Mar 13, 2019
1 parent b5cf92e commit 5e40dd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def del_addon(self, url):
return old['Name'], old['Version']
return False, False

def update_addon(self, url, update):
def update_addon(self, url, update, force):
old = self.check_if_installed(url)
if old:
new = self.parse_url(old['URL'])
new.get_current_version()
oldversion = old['Version']
modified = self.check_checksum(url)
if new.currentVersion != old['Version'] and not modified and update:
if new.currentVersion != old['Version'] and update and (not modified or force):
self.cleanup(old['Directories'])
new.install(self.path)
checksums = {}
Expand All @@ -122,7 +122,7 @@ def update_addon(self, url, update):
old['Directories'] = new.directories
old['Checksums'] = checksums
self.save_config()
return new.name, new.currentVersion, oldversion, modified
return new.name, new.currentVersion, oldversion, modified if not force else False
return url, False, False, False

def check_checksum(self, url):
Expand Down
13 changes: 9 additions & 4 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ def print_header(self):
f'{__version__}</ansibrightred> ~~~</ansibrightblack>\n'))

def setup_completer(self):
commands = ['install', 'uninstall', 'update', 'status', 'orphans', 'toggle_backup', 'uri_integration', 'exit']
commands = ['install', 'uninstall', 'update', 'force_update', 'status', 'orphans', 'toggle_backup',
'uri_integration', 'exit']
addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
for addon in addons:
commands.extend([f'uninstall {addon["Name"]}', f'update {addon["Name"]}', f'status {addon["Name"]}'])
commands.extend([f'uninstall {addon["Name"]}', f'update {addon["Name"]}', f'force_update {addon["Name"]}',
f'status {addon["Name"]}'])
self.completer = WordCompleter(commands, ignore_case=True, sentence=True)

def setup_table(self):
Expand Down Expand Up @@ -187,15 +189,15 @@ def c_uninstall(self, args):
'/wow/addons/[addon_name]\n\thttps://www.wowinterface.com/downloads/[addon_name]\n\tElvUI\n\tE'
'lvUI:Dev'))

def c_update(self, args, addline=False, update=True):
def c_update(self, args, addline=False, update=True, force=False):
if args:
addons = args.split(',')
else:
addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
with tqdm(total=len(addons), bar_format='{n_fmt}/{total_fmt} |{bar}|') as pbar:
for addon in addons:
name, versionnew, versionold, modified = self.core.\
update_addon(addon if isinstance(addon, str) else addon['URL'], update)
update_addon(addon if isinstance(addon, str) else addon['URL'], update, force)
if versionold:
if versionold == versionnew:
if modified:
Expand All @@ -215,6 +217,9 @@ def c_update(self, args, addline=False, update=True):
pbar.update(1)
print('\n' + self.table.table if addline else self.table.table)

def c_force_update(self, args):
self.c_update(args, False, True, True)

def c_status(self, args):
self.c_update(args, False, False)

Expand Down

0 comments on commit 5e40dd8

Please sign in to comment.