mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
ref: Rename folder to dir for consistency
This commit is contained in:
parent
917dcf31cf
commit
9794919fd2
8 changed files with 21 additions and 21 deletions
|
@ -50,7 +50,7 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fileManager.deleteFolder(
|
await fileManager.deleteDir(
|
||||||
`${sails.config.custom.attachmentsPathSegment}/${attachment.dirname}`,
|
`${sails.config.custom.attachmentsPathSegment}/${attachment.dirname}`,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -16,12 +16,12 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
const dirname = uuid();
|
const dirname = uuid();
|
||||||
const folderPathSegment = `${sails.config.custom.attachmentsPathSegment}/${dirname}`;
|
const dirPathSegment = `${sails.config.custom.attachmentsPathSegment}/${dirname}`;
|
||||||
const filename = filenamify(inputs.file.filename);
|
const filename = filenamify(inputs.file.filename);
|
||||||
|
|
||||||
const filePath = await fileManager.move(
|
const filePath = await fileManager.move(
|
||||||
inputs.file.fd,
|
inputs.file.fd,
|
||||||
`${folderPathSegment}/${filename}`,
|
`${dirPathSegment}/${filename}`,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
await fileManager.save(
|
await fileManager.save(
|
||||||
`${folderPathSegment}/thumbnails/cover-256.${thumbnailsExtension}`,
|
`${dirPathSegment}/thumbnails/cover-256.${thumbnailsExtension}`,
|
||||||
resizeBuffer,
|
resizeBuffer,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
const dirname = uuid();
|
const dirname = uuid();
|
||||||
const folderPathSegment = `${sails.config.custom.projectBackgroundImagesPathSegment}/${dirname}`;
|
const dirPathSegment = `${sails.config.custom.projectBackgroundImagesPathSegment}/${dirname}`;
|
||||||
|
|
||||||
let { width, pageHeight: height = metadata.height } = metadata;
|
let { width, pageHeight: height = metadata.height } = metadata;
|
||||||
if (metadata.orientation && metadata.orientation > 4) {
|
if (metadata.orientation && metadata.orientation > 4) {
|
||||||
|
@ -46,7 +46,7 @@ module.exports = {
|
||||||
const originalBuffer = await image.toBuffer();
|
const originalBuffer = await image.toBuffer();
|
||||||
|
|
||||||
await fileManager.save(
|
await fileManager.save(
|
||||||
`${folderPathSegment}/original.${extension}`,
|
`${dirPathSegment}/original.${extension}`,
|
||||||
originalBuffer,
|
originalBuffer,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
await fileManager.save(
|
await fileManager.save(
|
||||||
`${folderPathSegment}/cover-336.${extension}`,
|
`${dirPathSegment}/cover-336.${extension}`,
|
||||||
cover336Buffer,
|
cover336Buffer,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
@ -72,7 +72,7 @@ module.exports = {
|
||||||
console.warn(error1.stack); // eslint-disable-line no-console
|
console.warn(error1.stack); // eslint-disable-line no-console
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileManager.deleteFolder(folderPathSegment);
|
fileManager.deleteDir(dirPathSegment);
|
||||||
} catch (error2) {
|
} catch (error2) {
|
||||||
console.warn(error2.stack); // eslint-disable-line no-console
|
console.warn(error2.stack); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fileManager.deleteFolder(
|
await fileManager.deleteDir(
|
||||||
`${sails.config.custom.projectBackgroundImagesPathSegment}/${inputs.record.backgroundImage.dirname}`,
|
`${sails.config.custom.projectBackgroundImagesPathSegment}/${inputs.record.backgroundImage.dirname}`,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
const dirname = uuid();
|
const dirname = uuid();
|
||||||
const folderPathSegment = `${sails.config.custom.userAvatarsPathSegment}/${dirname}`;
|
const dirPathSegment = `${sails.config.custom.userAvatarsPathSegment}/${dirname}`;
|
||||||
|
|
||||||
let { width, pageHeight: height = metadata.height } = metadata;
|
let { width, pageHeight: height = metadata.height } = metadata;
|
||||||
if (metadata.orientation && metadata.orientation > 4) {
|
if (metadata.orientation && metadata.orientation > 4) {
|
||||||
|
@ -46,7 +46,7 @@ module.exports = {
|
||||||
const originalBuffer = await image.toBuffer();
|
const originalBuffer = await image.toBuffer();
|
||||||
|
|
||||||
await fileManager.save(
|
await fileManager.save(
|
||||||
`${folderPathSegment}/original.${extension}`,
|
`${dirPathSegment}/original.${extension}`,
|
||||||
originalBuffer,
|
originalBuffer,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
await fileManager.save(
|
await fileManager.save(
|
||||||
`${folderPathSegment}/square-100.${extension}`,
|
`${dirPathSegment}/square-100.${extension}`,
|
||||||
square100Buffer,
|
square100Buffer,
|
||||||
inputs.file.type,
|
inputs.file.type,
|
||||||
);
|
);
|
||||||
|
@ -72,7 +72,7 @@ module.exports = {
|
||||||
console.warn(error1.stack); // eslint-disable-line no-console
|
console.warn(error1.stack); // eslint-disable-line no-console
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileManager.deleteFolder(folderPathSegment);
|
fileManager.deleteDir(dirPathSegment);
|
||||||
} catch (error2) {
|
} catch (error2) {
|
||||||
console.warn(error2.stack); // eslint-disable-line no-console
|
console.warn(error2.stack); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ module.exports = {
|
||||||
const fileManager = sails.hooks['file-manager'].getInstance();
|
const fileManager = sails.hooks['file-manager'].getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fileManager.deleteFolder(
|
await fileManager.deleteDir(
|
||||||
`${sails.config.custom.userAvatarsPathSegment}/${inputs.record.avatar.dirname}`,
|
`${sails.config.custom.userAvatarsPathSegment}/${inputs.record.avatar.dirname}`,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -12,10 +12,10 @@ class LocalFileManager {
|
||||||
async move(sourceFilePath, filePathSegment) {
|
async move(sourceFilePath, filePathSegment) {
|
||||||
const { dir, base } = path.parse(filePathSegment);
|
const { dir, base } = path.parse(filePathSegment);
|
||||||
|
|
||||||
const folderPath = buildPath(dir);
|
const dirPath = buildPath(dir);
|
||||||
const filePath = path.join(folderPath, base);
|
const filePath = path.join(dirPath, base);
|
||||||
|
|
||||||
await fs.promises.mkdir(folderPath);
|
await fs.promises.mkdir(dirPath);
|
||||||
await fse.move(sourceFilePath, filePath);
|
await fse.move(sourceFilePath, filePath);
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
|
@ -38,8 +38,8 @@ class LocalFileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
async deleteFolder(folderPathSegment) {
|
async deleteDir(dirPathSegment) {
|
||||||
await rimraf(buildPath(folderPathSegment));
|
await rimraf(buildPath(dirPathSegment));
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
|
|
@ -45,10 +45,10 @@ class S3FileManager {
|
||||||
return result.Body;
|
return result.Body;
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteFolder(folderPathSegment) {
|
async deleteDir(dirPathSegment) {
|
||||||
const listObjectsCommand = new ListObjectsV2Command({
|
const listObjectsCommand = new ListObjectsV2Command({
|
||||||
Bucket: sails.config.custom.s3Bucket,
|
Bucket: sails.config.custom.s3Bucket,
|
||||||
Prefix: folderPathSegment,
|
Prefix: dirPathSegment,
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await this.client.send(listObjectsCommand);
|
const result = await this.client.send(listObjectsCommand);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue