mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Refactor ensureThumbnailCache to accept directoriesList parameter
This commit is contained in:
@ -279,7 +279,7 @@ async function preSetupTasks() {
|
|||||||
|
|
||||||
const directories = await getUserDirectoriesList();
|
const directories = await getUserDirectoriesList();
|
||||||
await checkForNewContent(directories);
|
await checkForNewContent(directories);
|
||||||
await ensureThumbnailCache();
|
await ensureThumbnailCache(directories);
|
||||||
await diskCache.verify(directories);
|
await diskCache.verify(directories);
|
||||||
cleanUploads();
|
cleanUploads();
|
||||||
migrateAccessLog();
|
migrateAccessLog();
|
||||||
|
@ -145,17 +145,16 @@ async function generateThumbnail(directories, type, file) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the thumbnail cache for backgrounds is valid.
|
* Ensures that the thumbnail cache for backgrounds is valid.
|
||||||
|
* @param {import('../users.js').UserDirectoryList[]} directoriesList User directories
|
||||||
* @returns {Promise<void>} Promise that resolves when the cache is validated
|
* @returns {Promise<void>} Promise that resolves when the cache is validated
|
||||||
*/
|
*/
|
||||||
export async function ensureThumbnailCache() {
|
export async function ensureThumbnailCache(directoriesList) {
|
||||||
const userHandles = await getAllUserHandles();
|
for (const directories of directoriesList) {
|
||||||
for (const handle of userHandles) {
|
|
||||||
const directories = getUserDirectories(handle);
|
|
||||||
const cacheFiles = fs.readdirSync(directories.thumbnailsBg);
|
const cacheFiles = fs.readdirSync(directories.thumbnailsBg);
|
||||||
|
|
||||||
// files exist, all ok
|
// files exist, all ok
|
||||||
if (cacheFiles.length) {
|
if (cacheFiles.length) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('Generating thumbnails cache. Please wait...');
|
console.info('Generating thumbnails cache. Please wait...');
|
||||||
|
Reference in New Issue
Block a user