Skip to content

Commit 3d8ebb0

Browse files
committed
add option to reset the metadata cache
1 parent 328eae4 commit 3d8ebb0

3 files changed

Lines changed: 37 additions & 12 deletions

File tree

dcoraid/dbmodel/db_api_cached.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ def get_users(self):
9494
"""Return the list of DCOR users"""
9595
return self.ai.get_users()
9696

97+
def reset_cache(self):
98+
self._mc_timestamp_path.unlink()
99+
self._mc_version_path.unlink()
100+
self._mc.reset()
101+
97102
def search_dataset(self, query="", limit=100):
98103
"""Search datasets via the CKAN API
99104

dcoraid/gui/panel_maintenance/widget_maintenance.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, *args, **kwargs):
2727

2828
self.pushButton_cache.clicked.connect(self.on_clear_cache)
2929
self.pushButton_drafts.clicked.connect(self.on_remove_drafts)
30+
self.pushButton_meta.clicked.connect(self.on_clear_meta)
3031

3132
@staticmethod
3233
def find_main_window():
@@ -55,6 +56,18 @@ def on_clear_cache(self):
5556
msg.setWindowTitle("Nothing to do")
5657
msg.exec()
5758

59+
@QtCore.pyqtSlot()
60+
def on_clear_meta(self):
61+
"""Clear local metadata cache"""
62+
self.find_main_window().database.reset_cache()
63+
QtWidgets.QMessageBox.information(
64+
self,
65+
"Metadata deleted",
66+
"All metadata databases have been removed from local "
67+
"storage. To continue working with DCOR-Aid, please select "
68+
"'Update DB' in the 'Find Data' tab."
69+
)
70+
5871
@QtCore.pyqtSlot()
5972
def on_remove_drafts(self):
6073
with ShowWaitCursor():

dcoraid/gui/panel_maintenance/widget_maintenance.ui

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
</property>
2525
</widget>
2626
</item>
27+
<item row="0" column="1">
28+
<spacer name="horizontalSpacer">
29+
<property name="orientation">
30+
<enum>Qt::Orientation::Horizontal</enum>
31+
</property>
32+
<property name="sizeHint" stdset="0">
33+
<size>
34+
<width>40</width>
35+
<height>20</height>
36+
</size>
37+
</property>
38+
</spacer>
39+
</item>
2740
<item row="1" column="0">
2841
<widget class="QPushButton" name="pushButton_cache">
2942
<property name="toolTip">
@@ -34,7 +47,7 @@
3447
</property>
3548
</widget>
3649
</item>
37-
<item row="2" column="0">
50+
<item row="3" column="0">
3851
<spacer name="verticalSpacer">
3952
<property name="orientation">
4053
<enum>Qt::Orientation::Vertical</enum>
@@ -47,18 +60,12 @@
4760
</property>
4861
</spacer>
4962
</item>
50-
<item row="0" column="1">
51-
<spacer name="horizontalSpacer">
52-
<property name="orientation">
53-
<enum>Qt::Orientation::Horizontal</enum>
54-
</property>
55-
<property name="sizeHint" stdset="0">
56-
<size>
57-
<width>40</width>
58-
<height>20</height>
59-
</size>
63+
<item row="2" column="0">
64+
<widget class="QPushButton" name="pushButton_meta">
65+
<property name="text">
66+
<string>Clear local metadata cache</string>
6067
</property>
61-
</spacer>
68+
</widget>
6269
</item>
6370
</layout>
6471
</widget>

0 commit comments

Comments
 (0)