refs #5576 perf: remove bad comments
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2023-12-19 08:44:11 +01:00
parent b2f569262a
commit c1e245c2ea
1 changed files with 9 additions and 29 deletions

View File

@ -74,15 +74,12 @@ module.exports = Self => {
Self.createLink = async(parent, child = null) => {
try {
const exists = await fs.exists(parent);
if (exists)
await fs.unlink(parent);
exists && await fs.unlink(parent);
} catch (e) {
throw new Error(e);
}
try {
await fs.symlink(child, parent);
const link = await fs.readlink(parent);
console.log(link);
} catch (e) {
throw new Error(e);
}
@ -96,17 +93,16 @@ module.exports = Self => {
}) {
const {name, dstDir} = await Self.handleFolderDestination(fileName);
try {
await models.Image.upsertWithWhere({
const baseUpsert = {
name,
collectionFk: collectionName,
},
{
name,
collectionFk: collectionName,
updated: Date.vnNow() / 1000,
});
};
await models.Image.upsertWithWhere(baseUpsert,
{
...baseUpsert,
updated: Date.vnNow() / 1000,
});
} catch (e) {
debugger;
throw new Error(e);
}
const collection = await Self.getCollection(collectionName);
@ -130,7 +126,6 @@ module.exports = Self => {
try {
await fs.mkdir(fullSizePath, {recursive: true});
} catch (e) {
debugger;
throw new Error(e);
}
const gmInstance = gm(srcFile);
@ -138,7 +133,7 @@ module.exports = Self => {
let fileHeight = null;
gmInstance.size(function(err, size) {
if (err) console.error(err);
if (err) throw new Error(err);
[fileWidth, fileHeight] = parseSize(size);
});
try {
@ -153,23 +148,10 @@ module.exports = Self => {
});
});
} catch (e) {
debugger;
throw new Error(e);
}
await Self.createLink(toFullSizeOriginalPath, toFullSizePath);
/* try {
await fs.unlink(toFullSizeOriginalPath);
} catch (e) {
debugger;
throw new Error(e);
}
try {
await fs.symlink(toFullSizeOriginalPath, toFullSizePath, 'file');
} catch (e) {
debugger;
throw new Error(e);
}*/
// To collection sizes
for (const size of collection.sizes()) {
const [width, height] = parseSize(size);
@ -182,7 +164,6 @@ module.exports = Self => {
try {
await fs.mkdir(sizePath, {recursive: true});
} catch (e) {
debugger;
throw new Error(e);
}
@ -216,7 +197,6 @@ module.exports = Self => {
const toSizeOriginalPath = `${sizeOriginalPath}/${fileName}`;
// if (fileWidth > width && fileHeight < height)
await Self.createLink(toSizeOriginalPath, toSizePath);
}
};