Skip to content

Commit 0c1b83e

Browse files
committed
Untested fix for renaming projects under wine
When renaming a newly created project under wine, this stack trace would greet you: Traceback (most recent call last): File "bash\basher\__init__.py", line 2208, in OnLabelEdited self.data_store.rename_info(package, name_new)) File "bash\bosh\__init__.py", line 1129, in rename_info return self._rename_operation(oldName, newName) File "bash\bosh\bain.py", line 1678, in _rename_operation return self[oldName].renameInstaller(newName, self) File "bash\bosh\bain.py", line 1532, in renameInstaller return self._installer_rename(data, name_new) File "bash\bosh\bain.py", line 982, in _installer_rename del data[g_path] File "bash\bolt.py", line 1254, in __delitem__ del self.data[key] KeyError: bolt.Path(u'test') Upon restarting, things would become even worse, with the entire Installers tab whited out. A different stack trace occured: Traceback (most recent call last): File "bash\basher\__init__.py", line 3553, in OnShowPage self.currentPage.ShowPanel() File "bash\balt.py", line 1796, in _conversation_wrapper return func(*args, **kwargs) File "bash\basher\__init__.py", line 2898, in ShowPanel scan_data_dir) File "bash\balt.py", line 1796, in _conversation_wrapper return func(*args, **kwargs) File "bash\bosh\bain.py", line 1552, in _projects_walk_cache_wrapper return func(self, *args, **kwargs) File "bash\basher\__init__.py", line 2928, in _refresh_installers_if_needed refresh_info) File "bash\bosh\bain.py", line 1636, in irefresh progress, fullRefresh, refresh_info, deleted, pending, projects) File "bash\bosh\bain.py", line 1552, in _projects_walk_cache_wrapper return func(self, *args, **kwargs) File "bash\bosh\bain.py", line 1774, in _refreshInstallers _index=index, _fullRefresh=fullRefresh) File "bash\bosh\bain.py", line 1790, in refresh_installer installer.refreshBasic(progress, recalculate_project_crc=_fullRefresh) File "bash\bosh\bain.py", line 859, in refreshBasic return self._refreshBasic(progress, recalculate_project_crc) File "bash\bosh\bain.py", line 866, in _refreshBasic self._refreshSource(progress, recalculate_project_crc) File "bash\bosh\bain.py", line 1432, in _refreshSource recalculate_project_crc) File "bash\bosh\bain.py", line 1364, in _refresh_from_project_dir max_mtime = apRoot.mtime File "bash\bolt.py", line 778, in _getmtime return int(os.path.getmtime(self._s)) File "C:\Python27\lib\genericpath.py", line 62, in getmtime return os.stat(filename).st_mtime WindowsError: [Error 2] File not found: u'\\home\\infernio\\.wine-bash\\drive_c\\Program Files\\Steam\\steamapps\\common\\Skyrim Mods\\Bash Installers\\test' Took a long time to figure out what's going on. I *think* this is because we carry out the shell move first, then hit a refresh due to wine / Linux / whatever weirdness, and that refresh removes the old installer from the BAIN data store and creates a new one for whatever you renamed it to. The proper solution would be to suspend refreshes while in _installer_rename (if the cause is indeed a refresh), i.e. making _instalelr_rename atomic from the perspective of refreshes. In the absence(?) of such a mechanism, we'll just go with two crappy if statements - seems to do the job, but is probably racy as hell.
1 parent 0c2eaf3 commit 0c1b83e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Mopy/bash/bosh/bain.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,18 @@ def _installer_rename(self, data, newName):
978978
newPath = bass.dirs['installers'].join(newName)
979979
if not newPath.exists():
980980
DataStore._rename_operation(data, g_path, newName)
981-
#--Add the new archive to Bash and remove old one
981+
# If we hit a refresh after that fs operation, BAIN may have
982+
# already deleted the old installer and created a new one for
983+
# the renamed path - undo that here
984+
# TODO(inf) This is quite hacky - we need some way to suspend
985+
# refreshes while in _installer_rename, i.e. make it atomic
986+
if g_path in data:
987+
del data[g_path]
988+
if newName in data:
989+
del data[newName]
990+
# Add the new archive to BAIN and remove old one
982991
data[newName] = self
983-
del data[g_path]
984-
#--Update the iniInfos & modInfos for 'installer'
992+
# Update the iniInfos & modInfos for 'installer'
985993
from . import modInfos, iniInfos
986994
mfiles = [x for x in modInfos.table.getColumn('installer') if
987995
modInfos.table[x]['installer'] == self.archive]

0 commit comments

Comments
 (0)