Skip to content

Commit

Permalink
Merge pull request arsenetar#1088 from arsenetar/as/remove-shelve
Browse files Browse the repository at this point in the history
feat: Remove shelve picture cache
  • Loading branch information
arsenetar authored Jan 10, 2023
2 parents 091cae0 + 83f5e80 commit a5e31f1
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 174 deletions.
6 changes: 1 addition & 5 deletions core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class DupeGuru(Broadcaster):

NAME = PROMPT_NAME = "dupeGuru"

PICTURE_CACHE_TYPE = "sqlite" # set to 'shelve' for a ShelveCache

def __init__(self, view, portable=False):
if view.get_default(DEBUG_MODE_PREFERENCE):
logging.getLogger().setLevel(logging.DEBUG)
Expand All @@ -153,7 +151,6 @@ def __init__(self, view, portable=False):
"clean_empty_dirs": False,
"ignore_hardlink_matches": False,
"copymove_dest_type": DestType.RELATIVE,
"picture_cache_type": self.PICTURE_CACHE_TYPE,
"include_exists_check": True,
"rehash_ignore_mtime": False,
}
Expand Down Expand Up @@ -185,8 +182,7 @@ def _recreate_result_table(self):
self.view.create_results_window()

def _get_picture_cache_path(self):
cache_type = self.options["picture_cache_type"]
cache_name = "cached_pictures.shelve" if cache_type == "shelve" else "cached_pictures.db"
cache_name = "cached_pictures.db"
return op.join(self.appdata, cache_name)

def _get_dupe_sort_key(self, dupe, get_group, key, delta):
Expand Down
141 changes: 0 additions & 141 deletions core/pe/cache_shelve.py

This file was deleted.

10 changes: 2 additions & 8 deletions core/pe/matchblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from core.engine import Match
from core.pe.block import avgdiff, DifferentBlockCountError, NoBlocksError
from core.pe.cache_sqlite import SqliteCache

# OPTIMIZATION NOTES:
# The bottleneck of the matching phase is CPU, which is why we use multiprocessing. However, another
Expand Down Expand Up @@ -50,14 +51,7 @@


def get_cache(cache_path, readonly=False):
if cache_path.endswith("shelve"):
from core.pe.cache_shelve import ShelveCache

return ShelveCache(cache_path, readonly=readonly)
else:
from core.pe.cache_sqlite import SqliteCache

return SqliteCache(cache_path, readonly=readonly)
return SqliteCache(cache_path, readonly=readonly)


def prepare_pictures(pictures, cache_path, with_dimensions, j=job.nulljob):
Expand Down
6 changes: 0 additions & 6 deletions core/tests/cache_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
try:
from core.pe.cache import colors_to_string, string_to_colors
from core.pe.cache_sqlite import SqliteCache
from core.pe.cache_shelve import ShelveCache
except ImportError:
skip("Can't import the cache module, probably hasn't been compiled.")

Expand Down Expand Up @@ -133,11 +132,6 @@ def test_corrupted_db(self, tmpdir, monkeypatch):
eq_(c["foo"], [(1, 2, 3)])


class TestCaseShelveCache(BaseTestCaseCache):
def get_cache(self, dbname=None):
return ShelveCache(dbname)


class TestCaseCacheSQLEscape:
def get_cache(self):
return SqliteCache()
Expand Down
1 change: 0 additions & 1 deletion qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def _update_options(self):
scanned_tags.add("year")
self.model.options["scanned_tags"] = scanned_tags
self.model.options["match_scaled"] = self.prefs.match_scaled
self.model.options["picture_cache_type"] = self.prefs.picture_cache_type
self.model.options["include_exists_check"] = self.prefs.include_exists_check
self.model.options["rehash_ignore_mtime"] = self.prefs.rehash_ignore_mtime

Expand Down
11 changes: 1 addition & 10 deletions qt/pe/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html

from PyQt5.QtWidgets import QFormLayout
from PyQt5.QtCore import Qt

from hscommon.trans import trget
from hscommon.plat import ISLINUX
from qt.radio_box import RadioBox
from core.scanner import ScanType
from core.app import AppMode

Expand All @@ -35,11 +33,6 @@ def _setupPreferenceWidgets(self):
)
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)

self.cacheTypeRadio = RadioBox(self, items=["Sqlite", "Shelve"], spread=False)
cache_form = QFormLayout()
cache_form.setLabelAlignment(Qt.AlignLeft)
cache_form.addRow(tr("Picture cache mode:"), self.cacheTypeRadio)
self.widgetsVLayout.addLayout(cache_form)
self._setupBottomPart()

def _setupDisplayPage(self):
Expand All @@ -64,7 +57,6 @@ def _setupDisplayPage(self):

def _load(self, prefs, setchecked, section):
setchecked(self.matchScaledBox, prefs.match_scaled)
self.cacheTypeRadio.selected_index = 1 if prefs.picture_cache_type == "shelve" else 0

# Update UI state based on selected scan type
scan_type = prefs.get_scan_type(AppMode.PICTURE)
Expand All @@ -75,6 +67,5 @@ def _load(self, prefs, setchecked, section):

def _save(self, prefs, ischecked):
prefs.match_scaled = ischecked(self.matchScaledBox)
prefs.picture_cache_type = "shelve" if self.cacheTypeRadio.selected_index == 1 else "sqlite"
prefs.details_dialog_override_theme_icons = ischecked(self.details_dialog_override_theme_icons)
prefs.details_dialog_viewers_show_scrollbars = ischecked(self.details_dialog_viewers_show_scrollbars)
3 changes: 0 additions & 3 deletions qt/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def _load_values(self, settings):
self.scan_tag_genre = get("ScanTagGenre", self.scan_tag_genre)
self.scan_tag_year = get("ScanTagYear", self.scan_tag_year)
self.match_scaled = get("MatchScaled", self.match_scaled)
self.picture_cache_type = get("PictureCacheType", self.picture_cache_type)

def reset(self):
self.filter_hardness = 95
Expand Down Expand Up @@ -278,7 +277,6 @@ def reset(self):
self.scan_tag_genre = False
self.scan_tag_year = False
self.match_scaled = False
self.picture_cache_type = "sqlite"

def _save_values(self, settings):
set_ = self.set_value
Expand Down Expand Up @@ -332,7 +330,6 @@ def _save_values(self, settings):
set_("ScanTagGenre", self.scan_tag_genre)
set_("ScanTagYear", self.scan_tag_year)
set_("MatchScaled", self.match_scaled)
set_("PictureCacheType", self.picture_cache_type)

# scan_type is special because we save it immediately when we set it.
def get_scan_type(self, app_mode):
Expand Down

0 comments on commit a5e31f1

Please sign in to comment.