@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
97 lines (96 loc) • 4.24 kB
JavaScript
/*
* Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com>
* This file is part of Sync-in | The open source file sync and share solution
* See the LICENSE file for licensing details
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SpacesScheduler", {
enumerable: true,
get: function() {
return SpacesScheduler;
}
});
const _common = require("@nestjs/common");
const _schedule = require("@nestjs/schedule");
const _sharesmanagerservice = require("../../shares/services/shares-manager.service");
const _spacesmanagerservice = require("./spaces-manager.service");
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
let SpacesScheduler = class SpacesScheduler {
async onStartup() {
await this.updateQuotas();
}
async updateQuotas() {
this.logger.log('Update Personal Quotas - START');
try {
await this.spacesManager.updatePersonalSpacesQuota();
} catch (e) {
this.logger.error(`Update Personal Quotas} - ${e}`);
}
this.logger.log('Update Personal Quotas - END');
this.logger.log('Update Space Quotas - START');
try {
await this.spacesManager.updateSpacesQuota();
} catch (e) {
this.logger.error(`Update Space Quotas - ${e}`);
}
this.logger.log('Update Space Quotas - END');
this.logger.log('Update Share External Path Quotas - START');
try {
await this.sharesManager.updateSharesExternalPathQuota();
} catch (e) {
this.logger.error(`Update Share External Path Quotas - ${e}`);
}
this.logger.log('Update Share External Path Quotas - END');
}
async deleteExpiredSpaces() {
/* Removes spaces that have been disabled for more than 30 days */ this.logger.log(`${this.deleteExpiredSpaces.name} - START`);
try {
await this.spacesManager.deleteExpiredSpaces();
} catch (e) {
this.logger.error(`${this.deleteExpiredSpaces.name} - ${e}`);
}
this.logger.log(`${this.deleteExpiredSpaces.name} - DONE`);
}
constructor(spacesManager, sharesManager){
this.spacesManager = spacesManager;
this.sharesManager = sharesManager;
this.logger = new _common.Logger(SpacesScheduler.name);
}
};
_ts_decorate([
(0, _schedule.Timeout)(60_000),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", []),
_ts_metadata("design:returntype", Promise)
], SpacesScheduler.prototype, "onStartup", null);
_ts_decorate([
(0, _schedule.Cron)(_schedule.CronExpression.EVERY_HOUR),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", []),
_ts_metadata("design:returntype", Promise)
], SpacesScheduler.prototype, "updateQuotas", null);
_ts_decorate([
(0, _schedule.Cron)(_schedule.CronExpression.EVERY_DAY_AT_2AM),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", []),
_ts_metadata("design:returntype", Promise)
], SpacesScheduler.prototype, "deleteExpiredSpaces", null);
SpacesScheduler = _ts_decorate([
(0, _common.Injectable)(),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof _spacesmanagerservice.SpacesManager === "undefined" ? Object : _spacesmanagerservice.SpacesManager,
typeof _sharesmanagerservice.SharesManager === "undefined" ? Object : _sharesmanagerservice.SharesManager
])
], SpacesScheduler);
//# sourceMappingURL=spaces-scheduler.service.js.map