|
|
@@ -87,27 +87,33 @@ module.exports = function(crowi) {
|
|
|
|
|
|
};
|
|
|
|
|
|
- lib.deleteFile = async function(attachment) {
|
|
|
+ lib.deleteFile = function(attachment) {
|
|
|
const filePath = getFilePathOnStorage(attachment);
|
|
|
- return lib.deleteFileByFilePath(filePath);
|
|
|
+ return lib.deleteFilesByFilePaths([filePath]);
|
|
|
};
|
|
|
|
|
|
- lib.deleteFiles = async function(attachments) {
|
|
|
- attachments.map((attachment) => {
|
|
|
- return this.deleteFile(attachment);
|
|
|
+ lib.deleteFiles = function(attachments) {
|
|
|
+ const filePaths = attachments.map((attachment) => {
|
|
|
+ return getFilePathOnStorage(attachment);
|
|
|
});
|
|
|
+ return lib.deleteFilesByFilePaths(filePaths);
|
|
|
};
|
|
|
|
|
|
- lib.deleteFileByFilePath = function(filePath) {
|
|
|
+ lib.deleteFilesByFilePaths = function(filePaths) {
|
|
|
if (!this.getIsUploadable()) {
|
|
|
throw new Error('GCS is not configured.');
|
|
|
}
|
|
|
|
|
|
const gcs = getGcsInstance();
|
|
|
const myBucket = gcs.bucket(getGcsBucket());
|
|
|
- const file = myBucket.file(filePath);
|
|
|
|
|
|
- return file.delete({ ignoreNotFound: true });
|
|
|
+ const files = filePaths.map((filePath) => {
|
|
|
+ return myBucket.file(filePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ files.forEach((file) => {
|
|
|
+ file.delete({ ignoreNotFound: true });
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
lib.uploadFile = function(fileStream, attachment) {
|