mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(imagecache): cleaned up dead code, reduced cache duration to 15 days
This commit is contained in:
@@ -20,7 +20,6 @@ Singleton {
|
||||
readonly property string baseDir: Settings.cacheDir + "images/"
|
||||
readonly property string wpThumbDir: baseDir + "wallpapers/thumbnails/"
|
||||
readonly property string wpLargeDir: baseDir + "wallpapers/large/"
|
||||
readonly property string wpOverviewDir: baseDir + "wallpapers/overview/"
|
||||
readonly property string notificationsDir: baseDir + "notifications/"
|
||||
readonly property string contributorsDir: baseDir + "contributors/"
|
||||
|
||||
@@ -73,17 +72,16 @@ Singleton {
|
||||
function createDirectories() {
|
||||
Quickshell.execDetached(["mkdir", "-p", wpThumbDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", wpLargeDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", wpOverviewDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", notificationsDir]);
|
||||
Quickshell.execDetached(["mkdir", "-p", contributorsDir]);
|
||||
}
|
||||
|
||||
function cleanupOldCache() {
|
||||
const dirs = [wpThumbDir, wpLargeDir, wpOverviewDir, notificationsDir, contributorsDir];
|
||||
const dirs = [wpThumbDir, wpLargeDir, notificationsDir, contributorsDir];
|
||||
dirs.forEach(function (dir) {
|
||||
Quickshell.execDetached(["find", dir, "-type", "f", "-mtime", "+30", "-delete"]);
|
||||
Quickshell.execDetached(["find", dir, "-type", "f", "-mtime", "+15", "-delete"]);
|
||||
});
|
||||
Logger.d("ImageCache", "Cleanup triggered for files older than 30 days");
|
||||
Logger.d("ImageCache", "Cleanup triggered for files older than 15 days");
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
@@ -250,31 +248,6 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// Public API: Get Blurred Overview (for Niri overview background)
|
||||
// -------------------------------------------------
|
||||
function getBlurredOverview(sourcePath, width, height, tintColor, isDarkMode, callback) {
|
||||
if (!sourcePath || sourcePath === "") {
|
||||
callback("", false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!imageMagickAvailable) {
|
||||
Logger.d("ImageCache", "ImageMagick not available for overview blur, using original:", sourcePath);
|
||||
callback(sourcePath, false);
|
||||
return;
|
||||
}
|
||||
|
||||
getMtime(sourcePath, function (mtime) {
|
||||
const cacheKey = generateOverviewKey(sourcePath, width, height, tintColor, isDarkMode, mtime);
|
||||
const cachedPath = wpOverviewDir + cacheKey + ".png";
|
||||
|
||||
processRequest(cacheKey, cachedPath, sourcePath, callback, function () {
|
||||
startOverviewProcessing(sourcePath, cachedPath, width, height, tintColor, isDarkMode, cacheKey);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// Cache Key Generation
|
||||
// -------------------------------------------------
|
||||
@@ -295,11 +268,6 @@ Singleton {
|
||||
return Checksum.sha256(imageUri);
|
||||
}
|
||||
|
||||
function generateOverviewKey(sourcePath, width, height, tintColor, isDarkMode, mtime) {
|
||||
const keyString = sourcePath + "@" + width + "x" + height + "@" + tintColor + "@" + (isDarkMode ? "dark" : "light") + "@" + (mtime || "unknown");
|
||||
return Checksum.sha256(keyString);
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// Request Processing (with coalescing)
|
||||
// -------------------------------------------------
|
||||
@@ -380,19 +348,6 @@ Singleton {
|
||||
runProcess(command, cacheKey, outputPath, sourcePath);
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// ImageMagick Processing: Blurred Overview
|
||||
// -------------------------------------------------
|
||||
function startOverviewProcessing(sourcePath, outputPath, width, height, tintColor, isDarkMode, cacheKey) {
|
||||
const srcEsc = sourcePath.replace(/'/g, "'\\''");
|
||||
const dstEsc = outputPath.replace(/'/g, "'\\''");
|
||||
|
||||
// Resize, blur, then tint overlay
|
||||
const command = `magick '${srcEsc}' -auto-orient -resize '${width}x${height}^' -gravity center -extent ${width}x${height} -gaussian-blur 0x5 \\( +clone -fill '${tintColor}' -colorize 100 -alpha set -channel A -evaluate set 50% +channel \\) -composite '${dstEsc}'`;
|
||||
|
||||
runProcess(command, cacheKey, outputPath, sourcePath);
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// ImageMagick Processing: Circular Avatar
|
||||
// -------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user