refs #5576 perf: remove bad try/catch declarations
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
55b737f376
commit
16cb42761e
|
@ -62,10 +62,6 @@ module.exports = Self => {
|
|||
Self.removeLink = async(child, parent = null) => {
|
||||
try {
|
||||
await fs.unlink(child);
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
try {
|
||||
await fs.symlink(parent, child);
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
|
@ -75,10 +71,6 @@ module.exports = Self => {
|
|||
try {
|
||||
const exists = await fs.exists(parent);
|
||||
exists && await fs.unlink(parent);
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
try {
|
||||
await fs.symlink(child, parent);
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
|
@ -102,41 +94,36 @@ module.exports = Self => {
|
|||
...baseUpsert,
|
||||
updated: Date.vnNow() / 1000,
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
const collection = await Self.getCollection(collectionName);
|
||||
const {maxWidth, maxHeight} = collection;
|
||||
|
||||
const collection = await Self.getCollection(collectionName);
|
||||
const {maxWidth, maxHeight} = collection;
|
||||
|
||||
// Update entity image file name
|
||||
const model = models[collection.model];
|
||||
if (!model) throw new Error('No matching model found');
|
||||
// Update entity image file name
|
||||
const model = models[collection.model];
|
||||
if (!model) throw new Error('No matching model found');
|
||||
|
||||
const entity = await model.findById(entityId);
|
||||
if (entity)
|
||||
await entity.updateAttribute(collection.property, name);
|
||||
const entity = await model.findById(entityId);
|
||||
if (entity)
|
||||
await entity.updateAttribute(collection.property, name);
|
||||
|
||||
// Resize
|
||||
const collectionDir = await Self.getCollectionDir(collectionName);
|
||||
// Resize
|
||||
const collectionDir = await Self.getCollectionDir(collectionName);
|
||||
|
||||
// To max size
|
||||
const _fullSizePath = Self.getFullSizePath(fileName, collectionDir, dstDir);
|
||||
// To max size
|
||||
const _fullSizePath = Self.getFullSizePath(fileName, collectionDir, dstDir);
|
||||
|
||||
const {fullSizePath, toFullSizePath, toFullSizeOriginalPath} = _fullSizePath;
|
||||
try {
|
||||
const {fullSizePath, toFullSizePath, toFullSizeOriginalPath} = _fullSizePath;
|
||||
|
||||
await fs.mkdir(fullSizePath, {recursive: true});
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
const gmInstance = gm(srcFile);
|
||||
let fileWidth = null;
|
||||
let fileHeight = null;
|
||||
|
||||
const gmInstance = gm(srcFile);
|
||||
let fileWidth = null;
|
||||
let fileHeight = null;
|
||||
|
||||
gmInstance.size(function(err, size) {
|
||||
if (err) throw new Error(err);
|
||||
[fileWidth, fileHeight] = parseSize(size);
|
||||
});
|
||||
try {
|
||||
gmInstance.size(function(err, size) {
|
||||
if (err) throw new Error(err);
|
||||
[fileWidth, fileHeight] = parseSize(size);
|
||||
});
|
||||
await new Promise((resolve, reject) => {
|
||||
gmInstance
|
||||
.resize(maxWidth, maxHeight, '>')
|
||||
|
|
Loading…
Reference in New Issue