create path if not exists #1538
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-06-19 07:36:36 +02:00
parent 1336bf092d
commit a89f00b463
1 changed files with 11 additions and 1 deletions

View File

@ -69,12 +69,22 @@ module.exports = Self => {
if (!hasWriteRole)
throw new UserError(`You don't have enough privileges`);
// Create final folder if not exists
const dmsType = await models.DmsType.findById(args.dmsTypeId);
await models.Container.getContainer(dmsType.path).catch(async err => {
if (err.code === 'ENOENT') {
await models.Container.createContainer({
name: dmsType.path
});
}
});
// Upload file to temporary path
const uploaded = await models.Container.upload('temp', ctx.req, ctx.result, fileOptions);
const files = Object.values(uploaded.files).map(file => {
return file[0];
});
const dmsType = await models.DmsType.findById(args.dmsTypeId);
const promises = [];
files.forEach(file => {