|
|
@@ -131,7 +131,7 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
|
|
|
// Auto import
|
|
|
// eslint-disable-next-line max-len
|
|
|
- receiveRouter.post('/', uploads.single('transferDataZipFile'), validateTransferKey, async(req: Request, res: ApiV3Response) => {
|
|
|
+ receiveRouter.post('/', uploads.single('transferDataZipFile'), validateTransferKey, async(req: Request & { file: any; }, res: ApiV3Response) => {
|
|
|
const { file } = req;
|
|
|
const {
|
|
|
collections: strCollections,
|
|
|
@@ -216,7 +216,7 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
|
|
|
// This endpoint uses multer's MemoryStorage since the received data should be persisted directly on attachment storage.
|
|
|
receiveRouter.post('/attachment', uploadsForAttachment.single('content'), validateTransferKey,
|
|
|
- async(req: Request, res: ApiV3Response) => {
|
|
|
+ async(req: Request & { file: any; }, res: ApiV3Response) => {
|
|
|
const { file } = req;
|
|
|
const { attachmentMetadata } = req.body;
|
|
|
|
|
|
@@ -314,23 +314,13 @@ module.exports = (crowi: Crowi): Router => {
|
|
|
// Check if can transfer
|
|
|
const transferability = await g2gTransferPusherService.getTransferability(toGROWIInfo);
|
|
|
if (!transferability.canTransfer) {
|
|
|
- logger.debug('Could not transfer.');
|
|
|
return res.apiv3Err(new ErrorV3(transferability.reason, 'growi_incompatible_to_transfer'));
|
|
|
}
|
|
|
|
|
|
// Start transfer
|
|
|
- try {
|
|
|
- await g2gTransferPusherService.startTransfer(tk, req.user, collections, optionsMap);
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- logger.error(err);
|
|
|
-
|
|
|
- if (!isG2GTransferError(err)) {
|
|
|
- return res.apiv3Err(new ErrorV3('Failed to transfer', 'failed_to_transfer'), 500);
|
|
|
- }
|
|
|
-
|
|
|
- return res.apiv3Err(new ErrorV3(err.message, err.code), 500);
|
|
|
- }
|
|
|
+ // DO NOT "await". Let it run in the background.
|
|
|
+ // Errors should be emitted through websocket.
|
|
|
+ g2gTransferPusherService.startTransfer(tk, req.user, collections, optionsMap);
|
|
|
|
|
|
return res.apiv3({ message: 'Successfully requested auto transfer.' });
|
|
|
});
|