Skip to content

Commit 8e5e14d

Browse files
committed
Fix project delete hash issue
1 parent 40377d2 commit 8e5e14d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

activity_browser/actions/project/project_delete.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import shutil
2+
13
from qtpy import QtWidgets
24

5+
import bw2data as bd
6+
from bw2data.project import ProjectDataset
7+
from bw2data.utils import safe_filename
8+
39
from activity_browser import settings, application
410
from activity_browser.actions.base import ABAction, exception_dialogs
5-
from activity_browser.mod import bw2data as bd
611
from activity_browser.ui.icons import qicons
712

813

@@ -74,6 +79,18 @@ def run(project_names: [str] = None):
7479
application.main_window, "Project(s) deleted", "Project(s) successfully deleted"
7580
)
7681

82+
@staticmethod
83+
def delete_project(name: str, delete_dir: bool):
84+
85+
ds = ProjectDataset.get(ProjectDataset.name == name)
86+
87+
if delete_dir:
88+
dir_path = bd.projects._base_data_dir / safe_filename(name, full=ds.full_hash)
89+
assert dir_path.is_dir(), "Can't find project directory"
90+
shutil.rmtree(dir_path)
91+
92+
ds.delete()
93+
7794

7895
class ProjectDeletionDialog(QtWidgets.QDialog):
7996

0 commit comments

Comments
 (0)