Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
bugfix: 修复一些逻辑错误
Browse files Browse the repository at this point in the history
- 修复:验证PinCode时候非预期的跳转行为
- 修复:删除同名prefix和object的冲突问题
- 修复:上传、下载不可用
- 优化:去除冗余的消息提示』
  • Loading branch information
zhanghao25 committed Aug 14, 2018
1 parent 19a9621 commit 22139c5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 51 deletions.
8 changes: 6 additions & 2 deletions app/bce/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export default class Login extends Component {
*
* @memberof Login
*/
setPinCode = () => {
setPinCode = (evt) => {
evt.preventDefault();

const {setPinCode} = this.props;
const {pin, pinconfirm} = this.state;

Expand Down Expand Up @@ -127,7 +129,9 @@ export default class Login extends Component {
*
* @memberof Login
*/
validatePinCode = () => {
validatePinCode = (evt) => {
evt.preventDefault();

if (this.state.pin === this.props.pin) {
ipcRenderer.send('notify', 'login_success');
} else {
Expand Down
7 changes: 0 additions & 7 deletions app/bos/actions/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/* eslint-disable object-property-newline */

import path from 'path';
import {notification} from 'antd';

import {getUuid} from '../../utils/helper';
Expand Down Expand Up @@ -88,12 +87,6 @@ export function createDownloadTask(bucketName, prefix, objectKeys, baseDir) {
totalSize, keymap
});

const [name] = path.posix.relative(prefix, objectKey).split('/');
notification.success({
message: '开始下载',
description: `准备下载 ${name},共计 ${Object.keys(keymap).length} 个文件`
});

dispatch(downloadStart([uuid]));
} catch (ex) {
notification.error({
Expand Down
12 changes: 0 additions & 12 deletions app/bos/actions/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import path from 'path';
import walk from 'fs-walk';
import {notification} from 'antd';

import {humanSize} from '../../utils';
import {getUuid} from '../../utils/helper';
import {UploadNotify, UploadCommandType} from '../utils/TransferNotify';

Expand Down Expand Up @@ -70,11 +69,6 @@ function _invokeFile(file, options = {}, dispatch) {
}
});

notification.success({
message: `上传 ${file.name}`,
description: `共计大小 ${humanSize(file.size)}。`
});

// 立即开始这个任务
dispatch(uploadStart([uuid]));
}
Expand All @@ -98,12 +92,6 @@ function _invokeFolder(relativePath, options = {}, dispatch) {
keymap
});

const keys = Object.keys(keymap);
notification.success({
message: `上传 ${folderName}`,
description: `共计 ${keys.length} 个文件, 文件大小 ${humanSize(totalSize)}`
});

// 立即开始这个任务
dispatch(uploadStart([uuid]));
}
Expand Down
49 changes: 24 additions & 25 deletions app/bos/actions/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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});
}
};
}

Expand Down
2 changes: 2 additions & 0 deletions app/bos/components/explorer/Explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export default class Explorer extends Component {
} catch (ex) {
notification.error({message: '删除失败', description: ex.message});
}

this._onReresh();
};

Modal.confirm({title: '删除提示', content: `您确定删除${toast}?`, onOk});
Expand Down
16 changes: 11 additions & 5 deletions app/bos/components/transfer/Transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ export default class Transfer extends Component {
const {category} = this.props;

if (category === TransCategory.Upload) {
this.renderUpload();
} else if (category === TransCategory.Download) {
this.renderDownload();
} else if (category === TransCategory.Complete) {
this.renderComplete();
return this.renderUpload();
}

if (category === TransCategory.Download) {
return this.renderDownload();
}

if (category === TransCategory.Complete) {
return this.renderComplete();
}

return null;
}

renderUpload() {
Expand Down

0 comments on commit 22139c5

Please sign in to comment.