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