|
@@ -26,6 +26,23 @@ module.exports = function(crowi) {
|
|
|
return true;
|
|
return true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ lib.deleteFile = async function(attachment) {
|
|
|
|
|
+ let filenameValue = attachment.fileName;
|
|
|
|
|
+
|
|
|
|
|
+ if (attachment.filePath != null) { // backward compatibility for v3.3.x or below
|
|
|
|
|
+ filenameValue = attachment.filePath;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const attachmentFile = await AttachmentFile.findOne({ filename: filenameValue });
|
|
|
|
|
+
|
|
|
|
|
+ if (attachmentFile == null) {
|
|
|
|
|
+ logger.warn(`Any AttachmentFile that relate to the Attachment (${attachment._id.toString()}) does not exist in GridFS`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return AttachmentFile.promisifiedUnlink({ _id: attachmentFile._id });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
lib.deleteFiles = async function(attachments) {
|
|
lib.deleteFiles = async function(attachments) {
|
|
|
|
|
|
|
|
attachments.map(async(attachment) => {
|
|
attachments.map(async(attachment) => {
|