mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-23 09:15:29 +01:00
Update debug logging
This commit is contained in:
parent
3f0f97f762
commit
4ffd679ddb
|
@ -87,16 +87,13 @@ export default class FileCacheProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async evictOldestIfNecessary() {
|
private async evictOldestIfNecessary() {
|
||||||
if (this.evictionQueue.size === 0 && this.evictionQueue.pending === 0) {
|
|
||||||
debug('Adding evictOldest task to queue');
|
|
||||||
void this.evictionQueue.add(this.evictOldest.bind(this));
|
void this.evictionQueue.add(this.evictOldest.bind(this));
|
||||||
}
|
|
||||||
|
|
||||||
return this.evictionQueue.onEmpty();
|
return this.evictionQueue.onEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async evictOldest() {
|
private async evictOldest() {
|
||||||
debug('Evicting oldest (if found)');
|
debug('Evicting oldest files...');
|
||||||
const [{dataValues: {totalSizeBytes}}] = await FileCache.findAll({
|
const [{dataValues: {totalSizeBytes}}] = await FileCache.findAll({
|
||||||
attributes: [
|
attributes: [
|
||||||
[sequelize.fn('sum', sequelize.col('bytes')), 'totalSizeBytes'],
|
[sequelize.fn('sum', sequelize.col('bytes')), 'totalSizeBytes'],
|
||||||
|
@ -113,14 +110,14 @@ export default class FileCacheProvider {
|
||||||
if (oldest) {
|
if (oldest) {
|
||||||
await oldest.destroy();
|
await oldest.destroy();
|
||||||
await fs.unlink(path.join(this.config.CACHE_DIR, oldest.hash));
|
await fs.unlink(path.join(this.config.CACHE_DIR, oldest.hash));
|
||||||
|
debug(`${oldest.hash} has been evicted`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue to evict until we're under the limit
|
// Continue to evict until we're under the limit
|
||||||
debug('Scheduling another eviction');
|
|
||||||
void this.evictionQueue.add(this.evictOldest.bind(this));
|
void this.evictionQueue.add(this.evictOldest.bind(this));
|
||||||
|
} else {
|
||||||
|
debug(`No files needed to be evicted. Total size of the cache is currently ${totalSizeBytes} bytes, and the cache limit is ${this.config.CACHE_LIMIT_IN_BYTES} bytes.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('Finished evictOldest');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async removeOrphans() {
|
private async removeOrphans() {
|
||||||
|
|
Loading…
Reference in a new issue