This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 修复:验证PinCode时候非预期的跳转行为 - 修复:删除同名prefix和object的冲突问题 - 修复:上传、下载不可用 - 优化:去除冗余的消息提示』
- Loading branch information
zhanghao25
committed
Aug 14, 2018
1 parent
19a9621
commit 22139c5
Showing
6 changed files
with
43 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
* @author mudio([email protected]) | ||
*/ | ||
|
||
import {info} from '../../utils/logger'; | ||
import _ from 'lodash'; | ||
|
||
import {API_TYPE} from '../middleware/api'; | ||
import {ClientFactory} from '../api/client'; | ||
import {REGION_BJ} from '../../utils/region'; | ||
|
@@ -62,33 +63,31 @@ export function deleteObject(bucketName, prefix, objects = []) { | |
return async dispatch => { | ||
const client = await ClientFactory.fromBucket(bucketName); | ||
|
||
const allTasks = objects.map(async key => { | ||
try { | ||
const keys = await client.listAllObjects(bucketName, key); | ||
|
||
const removeKeys = keys.map(item => item.key); | ||
info( | ||
'Delete bucketName = %s, prefix = %s, keys = %s', | ||
bucketName, prefix, removeKeys | ||
); | ||
|
||
const deferred = await dispatch({ | ||
[API_TYPE]: { | ||
types: [DELETE_OBJECT_REQUEST, DELETE_OBJECT_SUCCESS, DELETE_OBJECT_FAILURE], | ||
method: 'deleteAllObjects', | ||
args: [bucketName, removeKeys] | ||
} | ||
}); | ||
|
||
return deferred; | ||
} catch (error) { | ||
dispatch({type: DELETE_OBJECT_FAILURE, error}); | ||
const allTasks = objects.map(key => { | ||
if (key.endsWith('/')) { | ||
return client.listAllObjects(bucketName, key) | ||
.then(keys => keys.map(item => item.key)); | ||
} | ||
|
||
return Promise.resolve(key); | ||
}); | ||
|
||
return Promise.all(allTasks).then( | ||
() => dispatch(listObjects(bucketName, prefix)) | ||
); | ||
try { | ||
const removeKeys = await Promise.all(allTasks) | ||
.then(res => _.flatten(res)); | ||
|
||
const deferred = await dispatch({ | ||
[API_TYPE]: { | ||
types: [DELETE_OBJECT_REQUEST, DELETE_OBJECT_SUCCESS, DELETE_OBJECT_FAILURE], | ||
method: 'deleteAllObjects', | ||
args: [bucketName, removeKeys] | ||
} | ||
}); | ||
|
||
return deferred; | ||
} catch (error) { | ||
dispatch({type: DELETE_OBJECT_FAILURE, error}); | ||
} | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters