Skip to content

Commit

Permalink
Check can_rebuild faster and without false negatives.
Browse files Browse the repository at this point in the history
By just confirming all components are available, rather than rebuilding.  This has a chance of breaking saves cases where the installed_raws.txt is incorrect, but will skip unlogged saves and is essential if saves are to update at all.
  • Loading branch information
PeridexisErrant committed Feb 9, 2015
1 parent 2127270 commit beb724d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion core/baselines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import print_function, unicode_literals, absolute_import

import os, glob, zipfile, fnmatch
from io import open

from . import paths, update
from .lnp import lnp
Expand Down Expand Up @@ -135,7 +136,6 @@ def remove_vanilla_raws_from_pack(pack, folder):
i += 1
except UnicodeDecodeError:
pass

return i

def remove_empty_dirs(pack, folder):
Expand Down
29 changes: 5 additions & 24 deletions core/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,30 +275,11 @@ def can_rebuild(log_file, strict=True):
"""Test if user can exactly rebuild a raw folder, returning a bool."""
if not os.path.isfile(log_file):
return not strict
mods.clear_temp()
mods_list = mods.read_installation_log(log_file)
add_to_mods_merge(logged_graphics(log_file))
for m in mods_list:
mods.merge_a_mod(m)
save_raws = os.path.dirname(log_file)
gen_raws = paths.get('baselines', 'raw')
for root, _, files in os.walk(save_raws):
for k in files:
if not k.endswith('.txt'):
continue
f = os.path.relpath(os.path.join(root, k), save_raws)
if not os.path.isfile(os.path.join(gen_raws, f)):
return False
with open(os.path.join(gen_raws, f), mode='r', encoding='cp437',
errors='replace') as a:
with open(os.path.join(root, k), mode='r', encoding='cp437',
errors='replace') as b:
try:
if a.read() != b.read():
return False
except UnicodeDecodeError:
return False
return True
if (logged_graphics(log_file) in [k[0] for k in read_graphics()] and
all(m in mods.read_mods() for m in
mods.read_installation_log(log_file))):
return True
return False

def open_tilesets():
"""Opens the tilesets folder."""
Expand Down

0 comments on commit beb724d

Please sign in to comment.