Merge branch 'dev' into 1781-zoneHoliday
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
b8183748ce
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.deleteTrashFiles = async(options) => {
|
Self.deleteTrashFiles = async options => {
|
||||||
const tx = await Self.beginTransaction({});
|
const tx = await Self.beginTransaction({});
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
@ -26,6 +27,9 @@ module.exports = Self => {
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (process.env.NODE_ENV == 'test')
|
||||||
|
throw new UserError(`Action not allowed on the test environment`);
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const DmsContainer = models.DmsContainer;
|
const DmsContainer = models.DmsContainer;
|
||||||
|
|
||||||
|
@ -33,9 +37,15 @@ module.exports = Self => {
|
||||||
where: {code: 'trash'}
|
where: {code: 'trash'}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
const date = new Date();
|
||||||
|
date.setMonth(date.getMonth() - 4);
|
||||||
|
|
||||||
const dmsToDelete = await models.Dms.find({
|
const dmsToDelete = await models.Dms.find({
|
||||||
where: {
|
where: {
|
||||||
dmsTypeFk: trashDmsType.id
|
and: [
|
||||||
|
{dmsTypeFk: trashDmsType.id},
|
||||||
|
{created: {lt: date}}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
@ -43,14 +53,19 @@ module.exports = Self => {
|
||||||
const pathHash = DmsContainer.getHash(dms.id);
|
const pathHash = DmsContainer.getHash(dms.id);
|
||||||
const dmsContainer = await DmsContainer.container(pathHash);
|
const dmsContainer = await DmsContainer.container(pathHash);
|
||||||
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
|
const dstFile = path.join(dmsContainer.client.root, pathHash, dms.file);
|
||||||
|
const dstFolder = path.join(dmsContainer.client.root, pathHash);
|
||||||
await fs.unlink(dstFile);
|
await fs.unlink(dstFile);
|
||||||
await dms.destroy(myOptions);
|
try {
|
||||||
|
await fs.rmdir(dstFolder);
|
||||||
|
await dms.destroy(myOptions);
|
||||||
|
} catch (err) {
|
||||||
|
await dms.destroy(myOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `vn2008`.`albaran_gestdoc` DROP FOREIGN KEY fk_albaran_gestdoc_gestdoc1;
|
||||||
|
ALTER TABLE `vn2008`.`albaran_gestdoc` ADD CONSTRAINT albaran_gestdoc_FK FOREIGN KEY (gestdoc_id) REFERENCES `vn`.`dms`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -23,6 +23,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `account` /*!40100 DEFAULT CHARACTER SE
|
||||||
|
|
||||||
USE `account`;
|
USE `account`;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `account`
|
-- Table structure for table `account`
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue